Python Route Extensions
Python route extensions let an external package register additional HTTP routes on the Dynamo Frontend. The routes use the same port as the OpenAI-compatible API and do not require a custom binary or source build.
Extensions are opt-in. The Frontend loads only the providers selected with
--frontend-route-extension or DYN_FRONTEND_ROUTE_EXTENSIONS. A selection can be either:
- A name registered under the
dynamo.frontend.routesentry-point group, recommended for packaged extensions. - A direct
module:functionpath for development or one-off deployments.
Extensions add routes but cannot override built-in routes. A duplicate method and path combination causes Frontend startup to fail.
Routes use static paths and one of the GET, POST, PUT, PATCH, or DELETE methods. Path
parameters and wildcards are rejected.
Add a route extension
Define a route provider
A provider is a callable that returns a FrontendRoute or an iterable of routes. Each handler
receives a FrontendExtensionContext and returns either:
- A JSON-serializable body, which produces HTTP 200.
- A
FrontendResponsewith an explicit status code and body.
Register the provider
For an installable package, register the provider under the dynamo.frontend.routes entry-point
group. The entry-point name is the value passed to the Frontend.
Install the package so the entry point is discoverable:
Start the Frontend
Select the registered provider by name:
The equivalent environment-variable form is:
Call the added route:
The response is:
Load an importable provider directly
For development or a one-off deployment, pass an importable module:function path. The module must
be importable, for example by being available on PYTHONPATH.
A registered entry-point name takes precedence. The module:function fallback applies only when no
registered name matches and the value contains :.
Return a custom status
Return FrontendResponse when a handler needs a status other than HTTP 200:
FrontendExtensionContext provides a read-only view of live Frontend state through these methods:
is_ready()is_cancelled()has_any_ready_model()is_model_ready_to_serve(name)model_display_names()serving_ready_display_names()
Read the request and call workers
A handler can be an async def. Async handlers run on the Frontend’s asyncio event loop, so they can
await request-plane calls to workers. The context also carries the request and the Frontend’s
runtime:
body: the raw request body asbytes, empty when the request has none.headers: the request headers as adictwith lower-case names. Repeated headers are joined with", ".runtime: the Frontend’s ownDistributedRuntime, for clients to worker endpoints. Its async methods need the event loop, so call them from anasync defhandler.
The Frontend does not authenticate requests to extension routes, and it serves them on the same port as the inference API. A route that changes state must check credentials itself, as the following example does.
The following route takes a JSON body, checks a bearer token, sends the body to every instance of a worker endpoint, and returns the replies:
timeout_s sets the route’s handler timeout. It defaults to 30 seconds. max_body_bytes sets the
largest request body the route accepts. It defaults to 65536 (64 KiB).
Handler limits
Synchronous handlers execute in a small, dedicated thread pool, separate from inference tokenization. That pool also starts each async handler, which then runs on the Frontend’s event loop. Keep handlers fast and non-blocking:
- A handler that exceeds its route’s
timeout_s(30 seconds by default, counted from when the request body has been read) returns HTTP 503. An async handler is cancelled at the timeout. A call that a pool thread or the event loop picks up after its timeout is dropped without running the handler. A 503 does not mean the handler had no effect: it may have been cancelled partway. - A client that disconnects does not cancel a running handler.
- Each route admits at most 64 calls at once, waiting or running. A request beyond that, or one that finds the thread pool’s queue full, is rejected with the configured overload status code, HTTP 529 by default. An async handler holds its slot until its task ends, so a handler that catches the cancellation at the timeout keeps the slot until it returns.
- A handler that raises returns HTTP 500. That includes a
TimeoutErrorthe handler raises itself. - A request body larger than the route’s
max_body_bytes, 64 KiB by default, is rejected with HTTP 413.DYN_HTTP_BODY_LIMIT_MBdoes not apply to extension routes. - Slow work in a synchronous handler delays other extension routes: it occupies a pool thread, and
Python code holds the Global Interpreter Lock (GIL). In an async handler, a blocking call stalls
the Frontend’s event loop, which also runs Python chat processors (any
--dyn-chat-processorother thandynamo) and shutdown handling. Await the work or move it to a thread.
Load multiple providers
Repeat --frontend-route-extension to load multiple providers:
For the environment variable, use whitespace-separated values:
Provider names are de-duplicated. An unknown name fails startup and reports the available registered extensions.
For the complete flag and handler contract reference, see Frontend Configuration Reference.