Pass-through endpoints
A pass-through endpoint forwards a request to an upstream API without translating it. The client keeps using the provider's own API or SDK, while the gateway authenticates the caller with a virtual key, swaps in its own provider credential, enforces budgets and rate limits, and writes the call to the spend logs. Use it when a product needs a provider feature the unified endpoints do not cover, or when it must behave exactly as it does against the provider directly, but the provider key still has to stay out of the application.
There are two kinds. Built-in provider routes exist for the major providers and need only a credential. Custom pass-through endpoints are routes you define yourself, pointing any path on the gateway at any HTTP service, with optional headers, cost and guardrails.
A real-world scenario
An internal search team runs a rerank service at https://rerank.internal.example.com. Three product teams call it, each from its own servers, and the service key is pasted into each of them. The platform team adds a custom pass-through endpoint /v1/rerank-internal on the gateway with the service key in a header, sets a cost of 0.002 USD per call, and grants the route to the three teams. The product teams now call the gateway with their virtual keys, the service key lives in one place, every call is attributed and budgeted, and a PII guardrail runs on the query field before the request leaves the gateway.
Built-in provider routes
| Route | Upstream | Guide |
|---|---|---|
/openai_passthrough/{path} and /openai/{path} | OpenAI | OpenAI |
/anthropic/{path} | Anthropic | Anthropic |
/vertex_ai/{path} | Google Vertex AI | Vertex AI |
/gemini/{path} | Google AI Studio | Google AI Studio |
/bedrock/{path} | AWS Bedrock | Bedrock |
/azure/{path} and /azure_ai/{path} | Azure OpenAI and Azure AI | Azure |
/cohere/{path} | Cohere | Cohere |
/mistral/{path} | Mistral AI | Mistral |
/openrouter/{path} | OpenRouter | OpenRouter |
/nvidia_nim/{path}, where the path may start with a model group | NVIDIA NIM | NVIDIA NIM |
/watsonx/{path} | IBM watsonx.ai | watsonx.ai |
/vllm/{path} | Self-hosted vLLM | vLLM |
/fal_ai/{path} | Fal | Fal |
/cursor/{path} | Cursor Cloud Agents | Cursor |
/milvus/{path} | Milvus | Milvus |
/assemblyai/{path} and /eu.assemblyai/{path} | AssemblyAI | AssemblyAI |
/azure_speech/{path} | Azure AI Speech | Azure AI Speech |
/deepgram/v1/listen and /deepgram/listen (WebSocket) | Deepgram live transcription | Deepgram |
/comprehendmedical/{operation} | Amazon Comprehend Medical | Comprehend Medical |
/transcribe/{operation} | Amazon Transcribe | Transcribe |
/gigachat/{path} | GigaChat | GigaChat |
/langfuse/{path} | Langfuse | Langfuse |
/tinyfish/{path} | TinyFish Agent API | TinyFish |
/typesafe/{path} | Typesafe | Typesafe |
/laya/v1/systemone | Laya decision server | Laya |
/bespoke/v1/systemone | Bespoke Nimble decision server | Bespoke Nimble |
The provider credential for a built-in route comes from a model_list deployment of that provider with use_in_pass_through: true, and otherwise from the provider's <PROVIDER>_API_KEY environment variable. In the Admin UI the switch is Use in pass through routes under Advanced Settings on the Add Model tab of /ui/models-and-endpoints. Any valid virtual key may call a built-in route, unless the key's or team's denied_passthrough_routes lists it.
model_list:
- model_name: cohere-passthrough
spanway_params:
model: cohere/command-a-03-2025
api_key: os.environ/COHERE_API_KEY
use_in_pass_through: true
Custom pass-through endpoints
A custom endpoint maps a path on the gateway to a target URL. Define it in the config file, or create it from the Admin UI or the API, which stores it in the database and makes it live on the instance at once.
| Field | Meaning |
|---|---|
path | Route added to the gateway. |
target | URL the request is forwarded to. In the config file it can instead name a Python adapter (module.Class), which turns the route into a chat completion route that the adapter translates. |
headers | Headers added to the upstream request. Values may reference gateway environment variables with os.environ/, with the limits described below. |
default_query_params | Query parameters sent on every request, overridable by the client. |
include_subpath | Also forward subpaths of path, so /path/x goes to target/x. |
cost_per_request | Cost in US dollars recorded for each call. |
timeout | Upstream timeout in seconds. Defaults to general_settings.pass_through_request_timeout, which defaults to 600. |
auth | Require a Spanway key. Defaults to true. Set false only for a public forwarder such as a webhook target. |
methods | HTTP methods to accept. Empty means all of GET, POST, PUT, DELETE and PATCH. The same path can have a different target per method. |
guardrails | Guardrails to run on this route, see pass-through guardrails. |
forward_headers | Config file only, default false. On forwards the caller's request headers too, except host, content-length, accept-encoding and the headers the endpoint sets itself. That includes the caller's Authorization header unless the endpoint sets its own, so turn it on only for a target you trust with the Spanway key. |
merge_query_params | Config file only, default false. On sends the caller's query parameters together with default_query_params. |
Whatever forward_headers says, a client header named x-pass-<name> is always forwarded as <name>, so x-pass-anthropic-beta: tools-2026 reaches the target as anthropic-beta: tools-2026. Credential headers such as authorization, api-key and x-api-key cannot be set this way.
When a custom path collides with a built-in route, the custom route wins. Set the environment variable SPANWAY_BUILTIN_PASS_THROUGH_ROUTES_FIRST=true (default false) to let the built-in routes win instead, which keeps a stray custom endpoint from taking over a provider route.
Create a custom endpoint
-
In the Admin UI open
/ui/models-and-endpointsand click the Pass-Through Endpoints tab. It is shown to proxy admins who are not view-only. Click + Add Pass-Through Endpoint. -
Fill in Path Prefix
v1/rerank-internal, Target URLhttps://rerank.internal.example.com/v1/rerank, pick POST under HTTP Methods, turn Include Subpaths off, add an Authentication Headers row with nameAuthorizationand valuebearer os.environ/INTERNAL_RERANK_KEY, leave Require a Spanway virtual key on, set Cost Per Request (USD) to0.002and click Add Pass-Through Endpoint. The Route Preview card shows the gateway URL and the target before you save. The full dialog is described on the Models + Endpoints page. -
The same endpoint over the API, with a proxy admin key.
curl -X POST http://localhost:4000/config/pass_through_endpoint \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \-H "Content-Type: application/json" \-d '{"path": "/v1/rerank-internal", "target": "https://rerank.internal.example.com/v1/rerank", "headers": {"Authorization": "bearer os.environ/INTERNAL_RERANK_KEY"}, "default_query_params": {}, "include_subpath": false, "cost_per_request": 0.002, "timeout": null, "auth": true, "guardrails": null, "is_from_config": false, "methods": ["POST"]}'Or in the config file, which can read any environment variable and cannot be edited from the UI.
general_settings:pass_through_endpoints:- path: /v1/rerank-internaltarget: https://rerank.internal.example.com/v1/rerankheaders:Authorization: "bearer os.environ/INTERNAL_RERANK_KEY"include_subpath: falsecost_per_request: 0.002auth: truemethods: ["POST"] -
Call the new route with a virtual key.
curl -X POST http://localhost:4000/v1/rerank-internal \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"query": "refund for a duplicate charge", "documents": ["Refunds are issued within five business days."]}' -
Open
/ui/logsand click the newest row. The call is attributed to the key with a cost of 0.002 USD.
Expected result
The create call returns the stored endpoint with a generated id.
{"endpoints": [{"id": "9d2f6b1e-4c7a-4f0e-9a1b-2c3d4e5f6a7b", "path": "/v1/rerank-internal", "target": "https://rerank.internal.example.com/v1/rerank", "headers": {"Authorization": "bearer os.environ/INTERNAL_RERANK_KEY"}, "default_query_params": {}, "include_subpath": false, "cost_per_request": 0.002, "timeout": null, "auth": true, "guardrails": null, "is_from_config": false, "methods": ["POST"]}]}
The endpoint appears in the Pass-Through Endpoints table with Source DB, Authentication Yes and masked Headers. Calls to /v1/rerank-internal return the target's response unchanged. Keys that are not proxy admins get 403 on the route until it is granted to them, as described under route lists below.
Secrets in headers
GET /config/pass_through_endpoint masks header values whose name looks like a credential, such as Authorization or x-api-key, so the UI and the API show be****EY rather than the stored value. When you save an endpoint with a header still showing its masked value, the gateway keeps the stored secret, so editing other fields never overwrites the real credential. A header value typed as a literal is stored in plain text in the gateway database, in the general_settings row of Spanway_Config, so prefer an os.environ/ reference for secrets.
An endpoint created in the Admin UI or over the API can only read the gateway environment variables listed in general_settings.pass_through_env_var_allowlist. Without that check, anyone allowed to create an endpoint could point it at a server they control and add a header such as os.environ/SPANWAY_MASTER_KEY to read the gateway's own secrets. A create or update that references an unlisted variable is refused with 400 and names the variable, and a stored endpoint that still has one is loaded without that header. Endpoints defined in the config file can read any variable.
general_settings:
pass_through_env_var_allowlist:
- INTERNAL_RERANK_KEY
Endpoint management API
All management routes need a proxy admin key and a database. GET lists endpoints from the config file and the database, and takes endpoint_id or team_id to narrow the list, POST /config/pass_through_endpoint creates one, POST /config/pass_through_endpoint/{endpoint_id} updates the fields you send and keeps the rest, and DELETE /config/pass_through_endpoint?endpoint_id=... removes one. Config file endpoints are listed with is_from_config: true and cannot be updated or deleted here. Each create, update and delete writes an audit row with object_id pass_through_endpoint:<id> and the endpoint before and after, header values redacted.
| Method | Path | Summary |
|---|---|---|
| GET | /config/pass_through_endpoint/team/{team_id} | List the pass-through endpoints a team can call |
| GET | /config/pass_through_endpoint | List custom pass-through endpoints |
| POST | /config/pass_through_endpoint | Create a custom pass-through endpoint |
| DELETE | /config/pass_through_endpoint | Delete a custom pass-through endpoint |
| POST | /config/pass_through_endpoint/{endpoint_id} | Update a custom pass-through endpoint |
Route lists
A custom route with auth: true accepts a proxy admin key, and a non-admin key only when the route is granted to it. Grant a route by listing its path in allowed_passthrough_routes on the key or its team, or in a JWT team's team_allowed_routes. A path matches exactly or as a prefix, so /translate also grants /translate/v2. denied_passthrough_routes on the key or team blocks a route even when another list grants it, and also applies to the built-in provider routes.
Only a proxy admin can set either list, and both need the passthrough_routes license feature. Without it, custom routes still work for proxy admin keys and for routes set to auth: false. Organizations and projects refuse both fields, so set them on the keys or teams under them.
Grant a route to a team and check what the team can call
-
Open
/ui/teams, click the team, open its Settings tab, add/v1/rerank-internalunder Allowed Pass Through Routes and save. The field is enabled for proxy admins with the license feature. -
Or set the list over the API.
curl -X POST http://localhost:4000/team/update \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \-H "Content-Type: application/json" \-d '{"team_id": "team-search", "metadata": {"allowed_passthrough_routes": ["/v1/rerank-internal"], "denied_passthrough_routes": ["/v1/rerank-internal/admin"]}}'A key gets the same lists through its metadata.
curl -X POST http://localhost:4000/key/generate \-H "Authorization: Bearer $SPANWAY_MASTER_KEY" \-H "Content-Type: application/json" \-d '{"team_id": "team-search", "metadata": {"allowed_passthrough_routes": ["/v1/rerank-internal"]}}' -
Check what the team can reach. The Settings tab of the team shows Pass-through endpoints this team can call, the custom endpoints the team's keys reach after both lists are applied. The same list is available over the API to proxy admins.
curl http://localhost:4000/config/pass_through_endpoint/team/team-search \-H "Authorization: Bearer $SPANWAY_MASTER_KEY"
Expected result
The team listing returns every custom endpoint the team's keys can call, with header values masked. When the team has an allowed_passthrough_routes list, only the endpoints on it are returned. An endpoint with auth: true that matches denied_passthrough_routes is left out, while an endpoint with auth: false is never removed by the denied list because it accepts calls without a key anyway.
{"endpoints": [{"id": "9d2f6b1e-4c7a-4f0e-9a1b-2c3d4e5f6a7b", "path": "/v1/rerank-internal", "target": "https://rerank.internal.example.com/v1/rerank", "headers": {"Authorization": "be****EY"}, "default_query_params": {}, "include_subpath": false, "cost_per_request": 0.002, "timeout": null, "auth": true, "guardrails": null, "is_from_config": false, "methods": ["POST"]}]}
Spend and logging
Pass-through calls appear in the spend logs with the calling key, team and user. For the major LLM routes the gateway reads token usage from the provider response and costs it with the bundled price map. Custom routes are costed with cost_per_request. The Logs page at /ui/logs shows each call, and GET /spend/logs returns the same rows over the API.
Errors
| Status | Message | What it means and how to fix it |
|---|---|---|
401 | Authentication Error, Invalid proxy server token passed | The virtual key is missing, wrong, expired or blocked. Create a key on /ui/api-keys or check its status there. |
403 | Key/team not allowed to access passthrough route /v1/rerank-internal. Configure `allowed_passthrough_routes` on the team or key. | A non-admin key called a custom route with auth: true that is not granted to it. This also applies to a config file endpoint that leaves auth out, because auth defaults to true. Add the path under Allowed Pass Through Routes on the team or key. |
403 | Key/team denied access to passthrough route <route>. Matched `<entry>` in `denied_passthrough_routes`. | The key or team denies the route. Remove it from denied_passthrough_routes. |
403 | user not allowed to access this route. Route=/config/pass_through_endpoint is an admin only route | The management routes need a proxy admin key. |
403 | Only proxy admins can set `allowed_passthrough_routes` on a team. | A team admin tried to set a route list. Ask a proxy admin. |
400 | Pass-through headers may only read gateway environment variables listed in general_settings.pass_through_env_var_allowlist. Not allowed: Authorization -> SPANWAY_MASTER_KEY. ... | A header references an unlisted variable. Add the variable to the allowlist or define the endpoint in the config file. |
400 | The destination (target) changed while the stored secret (headers.Authorization) was left out or sent back masked. Re-enter the secret to use it with the new destination. | An update moved the endpoint to a new target with a header still masked. Type the header value again in the same save. |
400 | allowed_passthrough_routes and denied_passthrough_routes only apply to keys and teams, so a organization cannot carry them. ... | Route lists were sent on an organization or project. Set them on its keys or teams. |
400 | The `metadata.denied_passthrough_routes` must be a list of route strings. | The list is not a list of strings. Send ["/path"]. |
400 | DB not connected. This endpoint needs a database; set DATABASE_URL ... | Create ran on a gateway without a database, so endpoints can only come from the config file. Delete answers There are no pass-through endpoints setup. in the same case. |
400 | There are no pass-through endpoints setup. or Endpoint with ID '...' was not found in pass-through endpoint list. | The delete names no stored endpoint. Copy the id from the ID column of the table. |
404 | No pass-through endpoints found | An update ran with no stored endpoints, or without a database. |
404 | Endpoint with ID '...' not found, Could not find index for endpoint with ID '...' or Team not found | The update names no stored endpoint, or the team listing names no team. |
404 | Pass-through endpoint <path> not found. This could have been deleted or not yet added to the proxy. | The route was deleted, or this instance has not loaded it yet. Check the Pass-Through Endpoints tab. |
405 | Method <method> is not allowed for pass-through endpoint <path>. | The endpoint's methods list does not include this method. Add it or use a listed method. |
504 or a timeout | The upstream did not answer within timeout | Raise the endpoint's Request Timeout (seconds) or general_settings.pass_through_request_timeout. |
| Any other | The target's own error body | The target refused the request. The response is returned unchanged. |
Logs
| Level | Line | Meaning | Action |
|---|---|---|---|
| WARNING | pass through endpoint: dropping header <name>, its os.environ/<VAR> reference is not in general_settings.pass_through_env_var_allowlist | A stored endpoint lost a header at load time, so the target gets the request without it. | Add the variable to the allowlist, or move the endpoint to the config file. |
| WARNING | pass_through_endpoint: upstream <method> <url> returned <status>: <body> | The target answered with an error. The URL has no query string and the body is cut to 4096 characters, or shown as redacted when message logging is off for the request. The request body is never logged. | Check the target when it repeats. |
| WARNING | pass_through_endpoint: request blocked by guardrail - <message> | A pass-through guardrail refused the request. | None, unless the block was wrong. |
| WARNING | Skipping malformed pass-through endpoint from config: <error> | An endpoint in the config file has a wrong field, so it was not registered. | Fix the entry and restart. |
At DEBUG, the gateway also reports each custom route it registers (Initializing pass through endpoint and Added new pass through endpoint), the upstream URL with masked headers and the names of the body fields it forwards, and the credential lookup for the built-in provider routes, which says when no pass-through deployment was found and the environment variable was used instead.
Related
Each provider guide in the table above walks through one built-in route. Pass-through guardrails runs guardrails on custom routes, including field-level targeting. The Models + Endpoints page documents every control of the Pass-Through Endpoints tab, and the Teams page documents the team settings. Virtual keys explains keys, budgets and metadata, and access control explains the allowed route lists. MCP with AWS SigV4 covers MCP servers behind AWS IAM, which the gateway signs for in the same way as the Bedrock routes.