Skip to main content
In Flash, endpoints are the bridge between your local Python functions and Runpod’s cloud infrastructure. When you decorate a function with @Endpoint, you’re marking it to run remotely on Runpod instead of your local machine:
When you call run_model(data), Flash provisions a GPU on Runpod (or reuses an existing one), sends your function code and input to the worker, executes it, and returns the result to your local environment. Each unique endpoint name creates one Serverless endpoint on Runpod with its own URL, scaling configuration, and hardware allocation. The endpoint manages workers that scale up and down based on demand.

Endpoint types

The Endpoint class supports four distinct patterns.

Queue-based endpoints

Use @Endpoint(...) as a decorator for batch processing and async workloads. Each function gets its own endpoint with dedicated workers.
Queue-based endpoints are ideal for:
  • Batch processing jobs
  • Long-running computations
  • Workloads that don’t need immediate responses

Load-balanced endpoints

Use Endpoint(...) as an instance with route decorators for HTTP APIs. Multiple routes share the same workers.
Load-balanced endpoints are ideal for:
  • REST APIs with multiple routes
  • Low-latency request/response patterns
  • Services requiring custom HTTP methods

Custom Docker images

Deploy pre-built Docker images (like vLLM or your own workers) and interact with them as a client:
See Custom Docker images for complete documentation, including available images and configuration options.

Existing endpoints

Connect to an already-deployed Runpod endpoint by ID:

GPU vs CPU

Specify gpu= for GPU endpoints or cpu= for CPU endpoints. They are mutually exclusive.

GPU endpoints

If neither gpu= nor cpu= is specified, GPU defaults to GpuGroup.ANY.

CPU endpoints

See GPU types and CPU types for available options.

Worker scaling

Control how many workers run for your endpoint with the workers parameter:
Setting workers=(1, N) keeps at least one worker warm, avoiding cold starts.

Dependency management

Specify Python packages in the dependencies parameter. Flash installs these on the remote worker before executing your function.

Version pinning

Use standard pip syntax for version constraints:

Import packages inside the function body

You must import packages inside the decorated function body, not at the top of your file. This ensures imports happen on the remote worker. Correct: imports inside the function.
Incorrect: imports at top of file won’t work.

System dependencies

Use system_dependencies to install system-level packages (via apt):

Parallel execution

Endpoint functions are async. Use Python’s asyncio to run multiple operations concurrently:
This is useful for:
  • Batch processing multiple inputs
  • Running different models on the same data
  • Parallelizing independent pipeline stages

Environment variables

Pass environment variables using the env parameter:
Environment variables are excluded from configuration hashing. Changing environment values won’t trigger endpoint recreation, making it easy to rotate API keys.

Persistent storage

Attach a network volume for persistent storage across workers. Each volume is tied to a specific datacenter. Flash uses the volume name to find an existing volume or create a new one:
For multi-datacenter deployments, pass a list of volumes (one per datacenter):
See Flash storage for setup instructions.

Endpoint parameters

For a complete list of parameters available for the Endpoint class, see Endpoint parameters.

Working with jobs (client mode)

When using Endpoint(id=...) or Endpoint(image=...), you get an EndpointJob object for async operations:

Next steps

Custom Docker images

Deploy pre-built Docker images with Flash.

Build API endpoints

Create production APIs with Flash apps.

Deploy applications

Deploy Flash applications for production.

Clean up endpoints

Remove development endpoints when done testing.