Thank you for your interest in contributing to Runpod Flash Examples! This guide will help you create high-quality examples that benefit the community.
- Types of Contributions
- Example Standards
- Submission Process
- Example Structure
- Documentation Requirements
- Testing Guidelines
- Code Style
Add examples that demonstrate:
- Common use cases not yet covered
- Novel ML model deployments
- Production patterns and best practices
- Integration with third-party services
- Performance optimization techniques
- Bug fixes
- Performance optimizations
- Documentation improvements
- Additional features
- Better error handling
- Clarifying existing documentation
- Adding diagrams and visualizations
- Improving deployment guides
- Adding troubleshooting sections
All examples must meet these standards:
- Runs successfully with
flash run - All endpoints return correct responses
- Error handling is implemented
- Environment variables are documented
- Dependencies are declared in pyproject.toml
- Runtime deps declared in
Endpoint(dependencies=[...]) - Example discovered by
flash runfrom project root
- Clear, readable code
- Type hints for function signatures
- Async functions where appropriate
- No hardcoded credentials
- Proper logging (not print statements)
- Comprehensive README.md
- Code comments for complex logic
- API endpoint documentation
- Deployment instructions
- Cost estimates (if applicable)
- Input validation
- Error handling with meaningful messages
- Resource configuration (workers, timeout)
- Graceful degradation
- Security best practices
flash init to create new examples. Never copy-paste or duplicate existing example directories.
When creating a new example:
- Navigate to the appropriate category directory
- Use
flash initto create a clean project structure:cd 03_advanced_workers flash init my_new_example cd my_new_example
- Review existing examples in your category to understand patterns
- Implement your example with fresh code (don't copy-paste)
- Follow the structure and standards in the sections below
Why flash init?
- Ensures standard, up-to-date project structure
- Prevents propagation of outdated patterns
- Generates clean boilerplate
- Maintains consistency across examples
For AI Coding Assistants: If you're using Claude Code, Cursor, or similar tools, see CLAUDE.md for detailed AI-specific guidelines.
Place your example in the appropriate directory:
01_getting_started/- Basic concepts, simple examples02_ml_inference/- ML model serving03_advanced_workers/- Worker patterns and optimizations04_scaling_performance/- Production scaling patterns05_data_workflows/- Data handling and pipelines06_real_world/- Complete applicationsmisc/- Experimental or specialized examples
git clone https://github.com/YOUR_USERNAME/flash-examples.git
cd flash-examplesFollow the standard example structure.
cd your_category/your_example
flash run
# Test all endpointsflash run auto-discovers all .py files containing @Endpoint functions. Verify your example loads:
# From the repository root
flash run
# Check http://localhost:8888/docs for your new endpointsRuntime dependencies (torch, transformers, etc.) are declared in Endpoint(dependencies=[...]) and installed on the remote worker, not locally.
git checkout -b add-example-name
git add .
git commit -m "Add example: your_example_name"
git push origin add-example-nameCreate a PR with:
- Clear title: "Add example: [name]"
- Description of what the example demonstrates
- Any special requirements or considerations
- Screenshots/output examples (if applicable)
Each example is a flat directory with self-contained worker files (named *_worker.py by convention):
your_example/
├── README.md # Required: comprehensive documentation
├── gpu_worker.py # Required: GPU worker with @Endpoint decorator
├── cpu_worker.py # Optional: CPU worker with @Endpoint decorator
├── pyproject.toml # Required: project metadata and dependencies
├── .flashignore # Optional: files to exclude from deployment
├── tests/ # Recommended: test files
│ ├── test_workers.py
│ └── conftest.py
└── assets/ # Optional: images, diagrams, etc.
└── architecture.png
flash run discovers all .py files with @Endpoint functions automatically -- no main.py, no workers/ directories, no router wiring.
from runpod_flash import Endpoint, GpuType
@Endpoint(name="your-worker", gpu=GpuType.NVIDIA_GEFORCE_RTX_4090, dependencies=["torch"])
async def your_function(payload: dict) -> dict:
"""
Clear docstring explaining what this function does.
Args:
payload: Description of expected input
Returns:
Description of output format
"""
import torch
# your implementation
result = process(payload)
return {"status": "success", "result": result}
# Test locally
if __name__ == "__main__":
import asyncio
test_data = {"key": "value"}
result = asyncio.run(your_function(test_data))
print(result)Your example's README.md must include:
# Example Name
Brief one-line description.
## What This Demonstrates
- Concept 1
- Concept 2
- Concept 3
## Prerequisites
- Python 3.10+
- Runpod API key
- Any special requirements
## Quick Start
1. Install dependencies
2. Configure environment
3. Run locally
4. Test endpoints
## Architecture
Explain the design and data flow.
## Configuration
Document all environment variables and settings.
## Endpoints
Document each API endpoint with examples.
## Deployment
Step-by-step deployment instructions.
## Cost Estimates
Provide rough cost estimates for running this example.
## Troubleshooting
Common issues and solutions.
## Next Steps
Suggestions for extending the example.- Document why, not what
- Explain non-obvious decisions
- Add references to external docs
- Note performance considerations
- Highlight security concerns
Test your example thoroughly:
# Run the application
flash run
# Test health endpoint
curl http://localhost:8888/health
# Test your endpoints
curl -X POST http://localhost:8888/your/endpoint \
-H "Content-Type: application/json" \
-d '{"test": "data"}'
# Check API docs
open http://localhost:8888/docsThe repository includes VS Code debug configurations for endpoint development:
Setup:
-
Copy the root
.env.exampleto.env:cp .env.example .env
-
Add your Runpod API key to
.env:RUNPOD_API_KEY=your_actual_api_key_here
-
Ensure you have the Python extension installed in VS Code
Debugging:
Two debug configurations are available:
- Python Debugger: Current File - Debug any Python file
- Flash Worker: Debug Endpoint - Debug worker endpoint files with async support
To debug a worker:
- Open any
*_worker.pyfile (e.g.,01_getting_started/01_hello_world/hello_worker.py) - Set breakpoints in your worker functions
- Press F5 or select "Debug: Start Debugging"
- Choose the appropriate debug configuration
- The debugger will execute the
if __name__ == "__main__"test block
The .env file is automatically loaded, so your RUNPOD_API_KEY is available during debugging.
Add tests for your worker functions:
# tests/test_workers.py
import pytest
from your_example.gpu_worker import your_function
@pytest.mark.asyncio
async def test_your_function():
payload = {"key": "value"}
result = await your_function(payload)
assert result["status"] == "success"
assert "result" in resultRun tests:
pytest tests/Test deployment to verify it works on Runpod:
flash build
flash deploy new staging
flash deploy send staging
# Test the deployed endpoints- Follow PEP 8
- Use type hints
- Prefer async/await over callbacks
- Use descriptive variable names
- Keep functions focused and small
- Group related functionality
- Separate concerns (routing, logic, config)
- Use clear module names
- Avoid circular imports
# Good
import os
from dotenv import load_dotenv
load_dotenv()
RUNPOD_API_KEY = os.getenv("RUNPOD_API_KEY")
if not RUNPOD_API_KEY:
raise ValueError("RUNPOD_API_KEY is required")
# Bad
RUNPOD_API_KEY = "hardcoded_key" # Never do this!# Good - handle errors within @Endpoint functions
from runpod_flash import Endpoint, GpuType
# Good
@Endpoint(name="processor", gpu=GpuType.NVIDIA_GEFORCE_RTX_4090)
async def process(data: dict) -> dict:
try:
result = do_work(data)
return {"status": "success", "result": result}
except ValueError as e:
return {"status": "error", "detail": str(e)}
# Bad
@Endpoint(name="processor", gpu=GpuType.NVIDIA_GEFORCE_RTX_4090)
async def process(data: dict) -> dict:
result = do_work(data) # no error handling
return resultEach example declares only its local development dependencies in pyproject.toml. Runtime deps needed on the GPU (torch, transformers, etc.) go in Endpoint(dependencies=[...]):
[project]
name = "your-example"
version = "0.1.0"
description = "Brief description"
requires-python = ">=3.10"
dependencies = [
"runpod-flash",
]The root requirements.txt is a generated lockfile -- do not add per-example requirements.txt files.
-
Never commit secrets
- Use
.envfiles (gitignored) - The root
.env.exampledocuments required variables - Do not add per-example
.env.examplefiles
- Use
-
Validate inputs
- Use Pydantic models
- Sanitize user input
- Set reasonable limits
-
Authentication
- Document if authentication is needed
- Provide example implementation
- Use secure token handling
-
Dependencies
- Keep dependencies up to date
- Review security advisories
- Pin versions to avoid surprises
Pull requests will be reviewed for:
- Functionality: Does it work as described?
- Code Quality: Is it clean and maintainable?
- Documentation: Is it well documented?
- Standards: Does it follow guidelines?
- Security: Are there security concerns?
- Value: Does it add value to the repository?
Reviews typically take 2-7 days. Be patient and responsive to feedback.
- Questions: Open a GitHub Discussion
- Bugs: Open a GitHub Issue
- Chat: Join the Runpod Discord
- Docs: Check Flash Documentation
- Be respectful and inclusive
- Provide constructive feedback
- Focus on the code, not the person
- Help others learn and grow
By contributing, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Flash Examples! Your examples help the community build better AI applications.