Skip to main content

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.

MethodPathSummary
POST/v1/inspectDry 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):

FieldTypeRequiredDescription
cacheobject or nullNoCache controls, like the real call.
guardrailsarray of string or nullNoGuardrails the request asks for by name.
inspect_as_keystring or nullNoKey id (hashed token) to dry run as instead of the calling key. Proxy admins only.
max_tokensinteger or nullNoOutput tokens to price. Unset prices none.
messagesarray of objectNoChat messages of the request.
metadataobject or nullNoRequest metadata, read for tags.
modelstringYesModel, model group or '<model>@preset/<name>' the request would name.
presetstring or nullNoRouting preset as '@preset/<name>', like the real call.
tagsarray of string or nullNoRequest 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:

StatusDescriptionBody
200Successful Responseapplication/json InspectResponse
400The routing preset reference is malformed, or the preset lists no models and the request names none.application/json ErrorDetail
401No valid key or Admin UI session was presentedapplication/json ProxyError
403inspect_as_key was sent by a caller who is not a proxy admin.application/json ErrorDetail
404The routing preset or the inspect_as_key key does not exist.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
429The key used up its dry runs for this minute.application/json ErrorDetail
500The gateway has no database, which routing presets and inspect_as_key need.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
budgetsarray of InspectBudgetYesBudgets the request would draw from.
cache_statusenum: "disabled", "not_used", "hit", "miss"YesWhat the response cache would do for this request.
candidatesarray of InspectCandidateYesDeployments the router would choose from.
estimated_completion_tokensintegerYesOutput tokens priced, from max_tokens.
estimated_cost_usdnumber or nullYesEstimated cost in USD. Unset when the model has no price.
estimated_prompt_tokensintegerYesPrompt tokens counted on the messages.
guardrailsarray of InspectGuardrailYesEach guardrail's verdict and latency.
limitsarray of InspectLimitYesRate limits the request would count against.
modelstringYesModel the request named.
model_allowedbooleanYesWhether this key may call the resolved model.
model_denied_reasonstring or nullNoWhy the key may not call it.
policiesarray of InspectPolicyYesPolicies that match the request.
presetInspectPreset or nullNoRouting preset that applies, if any.
resolved_modelstringYesModel group the router would serve after presets and aliases.