Extension API Reference¶
This page documents non-OpenAI extension endpoints exposed by SMG, aligned to route registration in model_gateway/src/server.rs.
Auth Model¶
SMG endpoint auth is route-group based:
| Route group | Auth behavior |
|---|---|
| Public routes | No auth: /health, /liveness, /readiness, /health_generate, /engine_metrics, /loads, /v1/models, /v1/models/{model}, /get_model_info, and /get_server_info |
| Protected routes | Authorization: Bearer <key> with the shared --api-key or a per-tenant --tenant-api-key key; open when neither is set (/v1/tokenize, /generate, /v1/chat/completions, and the other inference routes) |
| Control-plane routes | With control-plane auth configured (--control-plane-api-keys, or --jwt-issuer with --jwt-audience), a control-plane API key or JWT: the admin role for every method, the user role for GET and HEAD only, except the admin-only reads GET /config and GET /rate-limits/tenants. Otherwise only the shared --api-key is accepted: per-tenant keys are rejected, a gateway with tenant keys but no --api-key answers every control-plane request with 401, and a gateway with no keys at all leaves these routes open |
With control-plane auth configured, a missing or invalid credential gets 401 and a valid credential whose role does not allow the method gets 403. The shared --api-key is not accepted on control-plane routes in that mode. The effective-configuration view (GET /config), the key reload (POST /secrets/reload), and the tenant rate-limit policy routes (GET and PUT /rate-limits/tenants) exist only in that mode: a gateway without control-plane auth does not mount them, so the paths answer 404 instead of falling back to the shared key.
If JWT validation fails to initialize at startup (for example, when OIDC discovery fails), the control-plane rules stay in force: keys from --control-plane-api-keys keep working, and JWTs and every other token get 401 until the gateway is restarted with a working JWT setup.
Public Extension Endpoints¶
These endpoints are registered without any auth middleware:
| Method | Path | Purpose |
|---|---|---|
GET |
/health |
Same as /liveness |
GET |
/liveness |
Process liveness probe |
GET |
/readiness |
Traffic readiness probe; see Gateway Probe Endpoints |
GET |
/health_generate |
Generation health check, forwarded to one HTTP worker or prefill/decode pair (see below); gRPC and ZMQ deployments answer 501 |
GET |
/engine_metrics |
The HTTP workers' own Prometheus metrics in one exposition; gRPC and ZMQ workers are named in comment lines, not scraped; see Engine Metrics Passthrough |
GET |
/loads |
Fleet engine load from the gateway's cached load snapshot (optional ?model= filter); see Get Loads |
GET |
/v1/models |
List models; see List Models |
GET |
/v1/models/{model} |
One model's card; {model} takes the rest of the path, so IDs with slashes work raw or percent-encoded; see Retrieve Model |
GET |
/get_model_info |
Model metadata, forwarded to a healthy HTTP worker whenever the fleet has one; a fleet with none answers 501 or 503 (see below) |
GET |
/get_server_info |
Server metadata, forwarded the same way as /get_model_info |
/health_generate makes the model generate tokens, so a PD-disaggregated HTTP deployment probes one prefill/decode pair selected by the routing policy rather than every worker. When both sides pass, the answer is 200 with a plain-text body naming the pair; each side that fails is listed in a 503 with code health_generate_failed, alongside the HTTP status it answered or, for a side that could not be reached, the transport's reason. A regular HTTP deployment forwards the probe to one healthy worker and returns that worker's own answer.
The route is public and a registered worker URL may carry a credential, so an answer that names a worker gives its masked address: anything in the URL's user:password@ part is masked whole (http://user:secret@gpu1:8000 becomes http://***@gpu1:8000), a query or fragment is cut, and an address with none of these parts appears exactly as registered. The transport's reason omits the request URL, so the answer carries no registered credential. The same rule masks worker addresses in log lines; see Worker Address Masking.
/get_model_info and /get_server_info are fleet-wide reads: the gateway forwards the GET to a healthy HTTP worker — a regular HTTP worker, or a disaggregated HTTP deployment's prefill worker — and returns that worker's answer. Whenever the fleet has such a worker, every call answers from one, even when gRPC or ZMQ workers serve the same gateway, and an HTTP deployment whose workers are all unhealthy is passed over for one that can answer. See Get Model Info and Get Server Info for the forwarded request and the response fields.
A fleet with no healthy HTTP worker answers an error instead: a gRPC or ZMQ deployment answers 501, an HTTP deployment whose workers are all unhealthy answers 503, and a fleet with both kinds answers one or the other, varying from call to call.
Protected Utility Endpoints¶
These run behind protected-route auth middleware:
| Method | Path | Purpose |
|---|---|---|
POST |
/v1/tokenize |
Convert text to token IDs |
POST |
/v1/detokenize |
Convert token IDs to text |
POST |
/generate |
Native generate endpoint |
POST |
/rerank |
Native rerank endpoint; model required |
POST |
/v1/rerank |
OpenAI-compatible rerank endpoint; routes by its optional model as /v1/embeddings does |
POST |
/v1/messages |
Messages endpoint |
POST |
/v1/messages/count_tokens |
Count the input tokens of a Messages request; see Count Tokens |
POST |
/v1/classify |
Classification endpoint |
POST |
/v1/decisions |
OpenAI Decisions API; regular HTTP workers and regular SGLang gRPC workers serve it, other backends answer 501. See Decisions |
POST |
/v1/embeddings |
OpenAI-compatible embeddings endpoint |
POST |
/v1/interactions |
Gemini Interactions API; only the Gemini provider backend serves it, other backends answer 501 |
POST |
/v1/systemone |
Native System One API; only regular HTTP workers serve it, deployments without a regular HTTP worker for the model answer 501 |
/generate is the native (SGLang-style) generation endpoint. SMG validates the body before any worker is involved, as it does for /v1/chat/completions: a rule violation answers 400 in the error envelope, with error.code naming the failure and error.param the offending field when one is known. A body that is not valid JSON is refused the same way with code invalid_json, one that parses but does not fit the request's shape with the envelope's schema codes (invalid_type, integer_below_min_value, ...), and a missing Content-Type: application/json header or any other parse failure with json_parse_error. A request the HTTP router streams to the worker unparsed skips these checks and is validated by the worker instead.
- The prompt is required: a body with none of
text,input_ids, andinput_embedsis refused asmissing_required_parameter. - An empty
textis refused asprompt_emptywithparamtextwhen the body carries noinput_idsand no media item inimage_data,video_data, oraudio_data(a media value holding only nulls and empty lists carries no item). Withinput_idspresent the emptytextis accepted (the engine reads the IDs, not the text); with a media item it is accepted as a media-only prompt.input_embedsdoes not lift the refusal, because the engine drops embeddings whentextis present. - An empty
input_ids— an empty array, an empty batch, or a batch holding an empty sequence — is refused asempty_arraywithparaminput_ids, as an emptymessagesis refused on the chat route. - A negative token ID anywhere in
input_ids, single or batched, is refused asinteger_below_min_valuewithparaminput_idsand a message naming the offending ID. The refusal comes from the gateway before routing, so HTTP-worker and gRPC-worker deployments answer it identically. sampling_paramsfields are checked against their bounds:temperatureandmax_new_tokensat least 0,top_pgreater than 0 and at most 1,top_keither-1(disabled) or at least 1,frequency_penaltyandpresence_penaltybetween -2 and 2,repetition_penaltybetween 0 and 2,min_pbetween 0 and 1, andnbetween 1 and 128 (the same bounds the chat route puts onn).error.codenames the bound crossed —decimal_below_min_valuefor a negativetemperature,decimal_above_max_valuefor atop_pabove 1,integer_below_min_valuefor annof 0,integer_above_max_valuefor annabove 128 — except for an out-of-rangetop_k, which answersinvalid_value;paramnames the field, for examplesampling_params.temperature.- Two cross-field rules in
sampling_paramsanswerinvalid_value:min_new_tokensmust not exceedmax_new_tokens(paramissampling_params.min_new_tokens), and only one ofregex,ebnf, andjson_schemamay be set (paramnames the second one set).
/rerank and /v1/rerank score a request's documents against its query and answer the ranked results. Regular HTTP workers serve the request at their own POST /v1/rerank, and a disaggregated HTTP deployment serves it through its prefill/decode pair (see PD disaggregation); other backends answer 501 with code rerank_not_implemented.
The native /rerank body requires model (which selects the worker), a non-blank query, and a non-empty documents array of strings, and takes an optional top_k (at least 1; all documents when absent), return_documents (default true), rid (a request ID, string or array), and user; a body that fails these checks answers 400.
/v1/rerank takes the OpenAI-compatible shape: the same fields with model optional and the limit spelled top_n (the native top_k spelling is read too; absent and 0 both mean all documents).
/v1/rerank routes by model exactly as /v1/embeddings does. A body that names a model goes to a worker serving it, and answers 404 with code model_not_found when none does; a body that names no model is routed as the unknown-model wildcard, to any worker. The wildcard is not written to the body forwarded to the worker, so a single-model rerank server applies its own model instead of refusing a name it does not serve.
When a regular HTTP worker or a disaggregated HTTP deployment's prefill/decode pair answers a success status, the gateway builds the response itself rather than passing the worker's through: object ("rerank"), model (the request's model, the canonical one when the request addressed a --model-alias name, and unknown when a /v1/rerank body named none), id (the request's rid when given, else the worker's id, else null), created, usage (the usage the worker reported, else null), and results, each result carrying score, index (the document's position in the request), the document text when requested and the worker echoed one, and the worker's meta_info when it sent one.
The gateway sorts the results by score, highest first, whatever order the worker used (a stable sort: equal scores keep the worker's order), then truncates to top_k/top_n and drops documents when return_documents is false, whatever the worker made of those fields — so a worker that answers unsorted does not lose its best documents to the cut.
The worker's answer is read in any HTTP rerank contract's shape: a bare JSON array of results, or a Cohere-style {"results": [...]} object, with the score spelled score or relevance_score and the document spelled document or text, given as a string or as a {"text": ...} object. The object form's usage (when spelled with prompt_tokens and total_tokens; an absent completion_tokens reads as 0) and id (a string or an array of strings) are carried into the gateway's response; a usage or id in another spelling or shape is left out, and the results are still read. The object's model is not read; the gateway names the model that ran. A bare-array answer carries no usage or id of its own, so its usage is null and its id is the request's rid when given, else null.
A success-status worker body in none of these shapes answers 502 with code call_upstream_decode_error, one larger than --max-payload-size answers 502 with code upstream_response_too_large, and one cut short in transit answers 502 with code read_response_body_failed; a worker error status passes through unchanged.
/v1/embeddings takes the optional OpenAI encoding_format field, which selects how each vector in the response's data is encoded: float answers the float array, as does leaving the field out, and base64 answers each vector as one string, the base64 of its little-endian f32 bytes, four bytes per value in order.
Who applies the field depends on the worker type. Regular SGLang and vLLM gRPC workers serve embeddings through their embed RPC, whose wire always carries floats, so the gateway encodes the answer itself: base64 gets the base64 strings, and float, an absent field, or any other value gets the float arrays. Regular HTTP workers serve the request at their own POST /v1/embeddings; the gateway forwards encoding_format to the worker with the rest of the body and returns the worker's response as is, so the two formats — and any engine-specific value — are the worker's to honor. Other backends do not serve embeddings and answer 501: disaggregated (PD and EPD) deployments (see Supported APIs), ZMQ workers, external providers, and TensorRT-LLM, MLX, and TokenSpeed gRPC workers.
/v1/systemone relays a non-streaming System One request to a regular HTTP worker's own /v1/systemone. Request fields SMG does not know are forwarded unchanged, and the worker's response — status, headers, and body, backend errors included — is returned as is.
Before relaying, SMG checks that model names a served model (unknown models answer 404), that state is text or structured JSON, and that questions maps at least one name to a question, with at least one criterion on each score question; a body that fails these checks answers 400.
These pages cover the other inference endpoints, which use the same auth:
- OpenAI-Compatible API:
/v1/chat/completions,/v1/completions,/v1/decisions,/v1/audio/transcriptions, and the/v1/realtimeroutes - Responses API:
/v1/responsesand/v1/conversations - Anthropic Messages API:
/v1/messagesand/v1/messages/count_tokens
Control-Plane Endpoints¶
These endpoints are for gateway operations and administration. They use the control-plane auth described in Auth Model.
By default they answer on the data listener (--port), alongside the serving routes. With --admin-port set, the endpoints in every section below and the RL control-plane routes answer on a dedicated admin listener instead, and the data listener answers 404 for them. The probe routes /health, /liveness, and /readiness answer on both listeners, so the admin listener can be checked on its own. The public /loads stays on the data listener, while its deprecated control-plane alias /get_loads moves with the rest.
The split changes where the routes answer, not who may call them: the auth above applies on the admin listener unchanged. See the Listeners reference and Admin Listener.
Worker Management¶
| Method | Path |
|---|---|
GET, POST |
/workers |
GET, PUT, PATCH, DELETE |
/workers/{worker_id} |
Tokenizer Management¶
| Method | Path |
|---|---|
GET, POST |
/v1/tokenizers |
GET, DELETE |
/v1/tokenizers/{tokenizer_id} |
GET |
/v1/tokenizers/{tokenizer_id}/status |
Parser Utilities¶
| Method | Path |
|---|---|
POST |
/parse/function_call |
POST |
/parse/reasoning |
WASM Management¶
| Method | Path |
|---|---|
GET, POST |
/wasm |
DELETE |
/wasm/{module_uuid} |
The WASM routes need --enable-wasm; without it they answer 503. Their refusals use the control plane's {"error", "code"} envelope; see WASM Module Management for the statuses and codes.
Profiling¶
| Method | Path | Purpose |
|---|---|---|
POST |
/start_profile |
Start the engine profiler on every worker, or only on the worker whose URL equals url in the optional JSON body |
POST |
/stop_profile |
Stop the profiler, with the same optional url |
/start_profile also accepts the engine's profiler options (output_dir, start_step, num_steps, activities, with_stack, record_shapes, profile_by_stage). SMG sends them as the JSON body of an HTTP worker's own /start_profile, or through the StartProfile RPC to SGLang, TokenSpeed, and vLLM gRPC workers. A TokenSpeed EPD encode worker refuses StartProfile and StopProfile, and is reported under failed (UNIMPLEMENTED). TensorRT-LLM gRPC, MLX gRPC, and ZMQ workers do not support profiling and are reported as failed. Both routes answer 200 when every targeted worker succeeds, 206 with successful and failed lists when any fails, and 404 when no worker matches.
A vLLM gRPC worker starts and stops the engine's own torch profiler on every rank; the trace directory and the profiler options are fixed by the engine's launch configuration and cannot be set per request. A /start_profile that sets any of the options above therefore lists vLLM workers under failed; to profile them, send a start that sets none of these options (a body with only url is fine).
Diagnostics¶
| Method | Path | Purpose |
|---|---|---|
GET |
/inflight |
The requests this gateway process is serving right now: its instance id and their sequence numbers |
POST |
/heap_profile |
A jemalloc heap profile of this gateway process, written under --jemalloc-prof-dir (a jemalloc-profiling build; 501 otherwise) |
GET |
/config |
The effective configuration with every secret redacted: the build identity, the secret sources, and the configuration with its keys named by fingerprint |
All three are control-plane routes, and GET /config is stricter: it is mounted only with control-plane auth configured (404 otherwise) and read by the admin role alone. See Diagnostics for the response shapes, the preconditions a heap profile needs, and the configuration view's redaction rules.
Key Reload¶
| Method | Path | Purpose |
|---|---|---|
POST |
/secrets/reload |
Read the start's key files again and put the rotated keys in force, without a restart |
Mounted only with control-plane auth configured (404 otherwise). Answers 200 with the files read and whether each key set changed, 409 when no key came from a file at start, and 422 when a file cannot be used — every key in force then stands. See Key Reload for the report shape and Key Rotation for the rotation workflow and the --secrets-auto-reload flag.
Tenant Rate-Limit Policy¶
| Method | Path | Purpose |
|---|---|---|
GET |
/rate-limits/tenants |
The tenant rate-limit document in force, with its revision and ETag |
PUT |
/rate-limits/tenants |
Replace the document against the ETag read (If-Match); ?dry_run=true reports the changes and applies nothing |
Both methods are mounted only with control-plane auth configured (404 otherwise), and the read is kept to the admin role like GET /config. Without --tenant-rate-limit-enabled they answer 409. See Tenant Rate-Limit Policy for the document shape, the headers, and every status code.
Cache and Load Utilities¶
| Method | Path | Purpose |
|---|---|---|
POST |
/flush_cache |
Flush the KV prefix cache on every worker that supports it |
GET |
/loads |
Fleet engine load from the gateway's cached load snapshot (optional ?model= filter) |
GET |
/get_loads |
Deprecated alias of /loads |
/loads is registered with the public routes and needs no auth; /flush_cache and the deprecated /get_loads alias are control-plane routes. See Cache Management for request and response details.
HA / Mesh Management Endpoints¶
SMG has no HTTP endpoints for mesh management; a request to any /ha/* path gets 404. Mesh routers talk to each other over gRPC on --mesh-port. To inspect a mesh, use the mesh metrics, the router logs, and each router's GET /workers; see High Availability.
RL Control Plane Endpoints¶
Mounted only when SMG starts with --enable-rl; without it, every /v1/rl/* path returns 404. These routes use the same auth as the other control-plane routes (see Auth Model).
| Method | Path | Purpose |
|---|---|---|
GET |
/v1/rl/workers |
List workers with engine, parallelism, health, weight version, and capabilities |
GET |
/v1/rl/workers/{id} |
One worker (404 worker_not_found for an unknown ID) |
GET, POST |
/v1/rl/workers/{id}/engine/{path} |
Forward one engine-native request to one worker's control endpoint; the response status mirrors the engine's |
GET, POST |
/v1/rl/engine/{path}?selector=... |
Send the same request to every worker matching a label selector; 200 when every target succeeds, 207 with per-worker failed[] otherwise |
See RL Control Plane for request and response shapes, selectors, errors, timeouts, metrics, and the smg.rl Python client.
Quick Examples¶
Tokenize:
curl -X POST http://localhost:30000/v1/tokenize \
-H "Content-Type: application/json" \
-d '{"model":"meta-llama/Llama-3.1-8B-Instruct","prompt":"hello"}'List workers. ADMIN_TOKEN is an admin control-plane API key or JWT when control-plane auth is configured, and the shared --api-key otherwise. With --admin-port set, this request and the tokenizer listing below go to the admin listener's port instead of the data port used here:
curl http://localhost:30000/workers \
-H "Authorization: Bearer ${ADMIN_TOKEN}"List tokenizers:
curl http://localhost:30000/v1/tokenizers \
-H "Authorization: Bearer ${ADMIN_TOKEN}"