vLLM pass-through
The /vllm route forwards requests to a self-hosted vLLM server. It covers the OpenAI-compatible paths vLLM serves and the vLLM-only ones the unified API does not, such as /classify, /score and /tokenize. The gateway checks the virtual key, forwards the request and records the spend. When the model in the body names a deployment from model_list, the gateway routes through that deployment, which means its api_base, retries and fallbacks apply.
A real-world scenario
A trust and safety team runs a vLLM classifier on an internal GPU box. Several services need /classify, which no unified endpoint offers, and nobody wants the GPU box reachable from everywhere. They register the vLLM server as a deployment on the gateway and the services call /vllm/classify with a virtual key. The box only accepts traffic from the gateway, and every classification is attributed to the calling service.
Before you start
The gateway needs the address of the vLLM server. It looks first for a model_list deployment of provider Hosted vLLM whose model_name matches the model in the body, then for the environment below.
| Variable | Purpose |
|---|---|
HOSTED_VLLM_API_BASE | The vLLM server address, such as http://vllm.internal:8000. |
HOSTED_VLLM_API_KEY | Optional. A key the vLLM server expects, sent as a bearer token. |
model_list:
- model_name: my-vllm-model
spanway_params:
model: hosted_vllm/my-vllm-model
api_base: http://vllm.internal:8000
use_in_pass_through: true
Steps
-
Register the server. Open
/ui/models-and-endpoints, on the Add Model tab pick Hosted vLLM under Provider, enter the model name and the server address under API Base, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or setHOSTED_VLLM_API_BASEand restart the gateway. -
Issue a virtual key on
/ui/api-keyswith + Create New Key, then Create Key. -
Call the vLLM server through the gateway.
curl -X POST http://localhost:4000/vllm/classify \-H "Authorization: Bearer $SPANWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"model": "my-vllm-model", "input": ["Please refund one of the two charges."]}' -
Open
/ui/logsand click the newest row to see the request and the key that made it.
Expected result
The vLLM server's own response, with its status code and headers. Streaming is streamed through as it arrives.
{
"id": "classify-2c1a",
"object": "list",
"model": "my-vllm-model",
"data": [{"index": 0, "label": "refund_request", "probs": [0.96, 0.04]}],
"usage": {"prompt_tokens": 9, "total_tokens": 9}
}
The spend log row carries the key, team and user. Set a price on the deployment under Custom Pricing to have each call costed.
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. |
403 | Key/team denied access to passthrough route /vllm/... | The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team. |
502 or connection error | Connection refused from the gateway's HTTP client | The gateway cannot reach the vLLM server. Check api_base or HOSTED_VLLM_API_BASE and the network path from the gateway. |
| Any other | The vLLM server's own error body | vLLM refused the request. The message is returned unchanged. |
Related
Pass-through endpoints lists every built-in route. The unified chat completions endpoint covers vLLM's OpenAI-compatible paths with guardrails and routing. The vLLM provider page covers the unified integration.