API Usage
List available models
Get a list of all configured targets in the OpenAI models format:
curl http://localhost:3000/v1/models
Sending requests
Send requests to the gateway using the standard OpenAI API format:
curl -X POST http://localhost:3000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
The model field determines which target receives the request.
Model override header
Override the target using the model-override header. This routes the request to a different target regardless of the model field in the body:
curl -X POST http://localhost:3000/v1/chat/completions \
-H "model-override: claude-3" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
This is also used for routing requests without bodies – for example, to get the embeddings usage for your organization:
curl -X GET http://localhost:3000/v1/organization/usage/embeddings \
-H "model-override: claude-3"
Metrics
When the --metrics flag is enabled (the default), Prometheus metrics are exposed on a separate port:
curl http://localhost:9090/metrics
See Command Line Options for metrics configuration flags.
Rejected requests
Every client error that onwards decides on itself, such as an unknown model, a failed reasoning check, a strict-mode schema error or a rate limit, increments onwards_rejections_total{model, serving_class, status, code, traffic}:
codeis the error code returned to the client. Strict-mode body errors carry no code, so they are counted as:invalid_json: malformed JSON;schema_mismatch: valid JSON that doesn’t match the schema;invalid_content_type: a/v1/responsesbody not sent as JSON;invalid_body: a/v1/responsesbody that couldn’t be read.
modelis the configured model the request names, without the serving-class suffix of a class route. It is empty when the request names no configured model.serving_classis the class of a class route (a target whose pool setsclass_route_of, namedmodel:<class>), andstandardotherwise. The per-request in-flight, limit, failure and first-token metrics carry the same pair, so a model aggregates across its classes or splits by class.trafficisdispatchedfor requests carrying the first-token-timeout exempt header andrealtimeotherwise.
Each rejection also sets these attributes on the current trace span, usually onwards’ onwards.request span. Strict mode refuses some requests before that span exists (body errors, payload too large, unsupported /v1/completions and Responses reasoning fields). Those attributes go on the enclosing span when onwards runs inside a gateway that opens one per request, such as dwctl; the standalone server opens none, so they are only counted there:
error.type: the same code as the metric;onwards.rejection.param: the parameter the error names, if any. Forschema_mismatchit is where the body stopped matching, such asmessages[].tool_calls[].function.arguments: array positions are left out, and so is anything the request contained. The client’s error carries the same value inparam;onwards.rejection.reason: forschema_mismatch, how the body failed:invalid_type,invalid_value,invalid_length,unknown_variant,unknown_field,missing_field,duplicate_field,no_matching_variantorother;onwards.accountandonwards.api_key_id: from the labels of the key the request presented, when it has them;http.response.status_code: ononwards.request.
Request parameter values and request bodies are never recorded. A client error that reports an upstream’s response isn’t counted.
A gateway that embeds onwards can count the requests its own layers refuse in the same series, with onwards::rejections::RejectionContext::for_api_key. dwctl records the refusals of its body limit, inference routing, protocol translation, prompt cache, continuation, request preparation, image normalisation and /models list there. A layer that only rewrites a refusal onwards made, such as dwctl’s error enrichment, doesn’t record it again.