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 pip/installed packages inside the decorated function body, not at the top of your file. This ensures imports happen on the remote worker. This rule applies to installed packages only; local project modules can be imported at the top of the file because Flash ships their source (see Import local modules). 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):

Import local modules

Your endpoint can import local (non-pip) Python modules that live alongside it in your project, such as a sibling utils.py file or a helpers/ package. Flash detects these imports, follows them transitively, and ships the module source to the worker for you, so an import like import utils or from helpers import load works remotely with no extra configuration. Flash resolves local imports whether they appear at the top of the file or inside the function body, and it supports absolute imports (import utils), relative imports (from . import helpers), and dynamic imports with a literal name (importlib.import_module("plugin")). It also pulls in the __init__.py files for any packages you import. Flash can’t resolve dynamic imports whose module name is computed at runtime, so it emits a warning, and you’re responsible for making those modules available on the worker. Flash bundles only local project files. Standard library modules are already present in the worker image, and pip packages must still be declared through the dependencies parameter. This applies transitively: if a bundled local module imports a pip package at its top level, that package must still be declared in the dependencies of any endpoint that uses the module. On flash build and flash deploy, local modules are bundled when they pass the ignore filter, and importing a local module that an ignore rule excludes (or one Flash can’t resolve) fails the build. See Local modules and the ignore filter for details.

Live execution size limit

When you run an endpoint live (calling an @Endpoint function directly, or during flash dev), Flash ships the resolved module source inline with the request. The combined source is capped at 8 MiB. If your local dependencies exceed this limit, deploy the app with flash deploy instead, which bundles local modules into the build artifact rather than the request payload. See Local module payload too large for the corresponding error.

Local modules in a parent directory

On the live execution path, Flash treats a module imported by absolute name from a parent directory as external and doesn’t ship it, which causes a ModuleNotFoundError on the worker. For example, this happens with import shared when shared.py sits above your endpoint file. To avoid it, place your endpoint at or above its local dependencies, or use flash deploy, which resolves imports against the whole project directory.

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.