Inspect API
This page documents the 1 gateway endpoint tagged inspect in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| POST | /v1/inspect | Dry run a chat completion |
Endpoints
POST /v1/inspect
Dry run a chat completion
See what a chat completion would do before you send it. Send the same body you would send to
/v1/chat/completions with the same key. The answer shows the model the gateway would use after routing
presets and aliases, whether the key may call it, the deployments it would pick from and why any are passed
over, the policies that match and each guardrail's verdict and latency on these messages, whether the response
cache would answer, the estimated cost, and the budgets and rate limits the request would count against. No
model is called and no spend, budget or rate limit counter changes. Each key gets its own small dry run
allowance per minute (INSPECT_RPM_LIMIT, 60 by default, or the key's rpm limit when lower), and every dry run
writes an audit row without the messages. Guardrails run only when the key may call the model, a guardrail
that calls an outside service is billed by that service as usual, and only proxy admins see guardrail detail.
A proxy admin can set inspect_as_key to a key id to see what that key's request would do. The dry run then
uses that key's access, budgets and limits but counts against the admin's own allowance, a blocked or expired
key comes back with model_allowed false and the reason, the audit row names both the admin and the key, and any
other caller who sets it gets 403.
Example curl:
curl -X POST http://0.0.0.0:4000/v1/inspect \\
-H "Authorization: Bearer sk-admin" -H "Content-Type: application/json" \\
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Summarise ticket 4411"}], "max_tokens": 300}'
Request body (application/json, schema InspectRequest):
| Field | Type | Required | Description |
|---|---|---|---|
cache | object or null | No | Cache controls, like the real call. |
guardrails | array of string or null | No | Guardrails the request asks for by name. |
inspect_as_key | string or null | No | Key id (hashed token) to dry run as instead of the calling key. Proxy admins only. |
max_tokens | integer or null | No | Output tokens to price. Unset prices none. |
messages | array of object | No | Chat messages of the request. |
metadata | object or null | No | Request metadata, read for tags. |
model | string | Yes | Model, model group or '<model>@preset/<name>' the request would name. |
preset | string or null | No | Routing preset as '@preset/<name>', like the real call. |
tags | array of string or null | No | Request tags, used for policy matching. |
Example request:
curl -X POST "http://localhost:4000/v1/inspect" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5"
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful Response | application/json InspectResponse |
| 400 | The routing preset reference is malformed, or the preset lists no models and the request names none. | application/json ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | inspect_as_key was sent by a caller who is not a proxy admin. | application/json ErrorDetail |
| 404 | The routing preset or the inspect_as_key key does not exist. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 429 | The key used up its dry runs for this minute. | application/json ErrorDetail |
| 500 | The gateway has no database, which routing presets and inspect_as_key need. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
budgets | array of InspectBudget | Yes | Budgets the request would draw from. |
cache_status | enum: "disabled", "not_used", "hit", "miss" | Yes | What the response cache would do for this request. |
candidates | array of InspectCandidate | Yes | Deployments the router would choose from. |
estimated_completion_tokens | integer | Yes | Output tokens priced, from max_tokens. |
estimated_cost_usd | number or null | Yes | Estimated cost in USD. Unset when the model has no price. |
estimated_prompt_tokens | integer | Yes | Prompt tokens counted on the messages. |
guardrails | array of InspectGuardrail | Yes | Each guardrail's verdict and latency. |
limits | array of InspectLimit | Yes | Rate limits the request would count against. |
model | string | Yes | Model the request named. |
model_allowed | boolean | Yes | Whether this key may call the resolved model. |
model_denied_reason | string or null | No | Why the key may not call it. |
policies | array of InspectPolicy | Yes | Policies that match the request. |
preset | InspectPreset or null | No | Routing preset that applies, if any. |
resolved_model | string | Yes | Model group the router would serve after presets and aliases. |