Skip to main content

Mistral pass-through

The /mistral route forwards Mistral API paths, such as /v1/chat/completions, /v1/ocr and /v1/agents/completions, to Mistral unchanged. Teams keep the Mistral SDK and reach Mistral-only features such as OCR and agents, while the gateway holds the Mistral key, checks the virtual key and records the spend.

A real-world scenario​

A document team runs invoices through Mistral OCR, which the unified API does not cover. They call /mistral/v1/ocr on the gateway with a virtual key. The Mistral key stays on the gateway, the team's budget applies, and each OCR call appears on the Logs page.

Before you start​

The gateway needs a Mistral credential. It looks first for a model_list deployment of provider Mistral with use_in_pass_through: true, then for the environment below.

VariablePurpose
MISTRAL_API_KEYThe Mistral key the gateway sends upstream.
MISTRAL_API_BASEOptional. Changes the upstream address from https://api.mistral.ai.

Steps​

  1. Give the gateway the credential. Open /ui/models-and-endpoints, on the Add Model tab pick Mistral AI under Provider, pick a model, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or set MISTRAL_API_KEY and restart the gateway.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Call Mistral through the gateway.

    curl -X POST http://localhost:4000/mistral/v1/chat/completions \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "mistral-large-4", "messages": [{"role": "user", "content": "Summarise this ticket in one sentence."}]}'
  4. Open /ui/logs and click the newest row to see the request, the key and its cost.

Expected result​

Mistral's own response, with Mistral's status code and headers. Streaming is streamed through as it arrives.

{
"id": "chatcmpl-9f1c",
"object": "chat.completion",
"model": "mistral-large-4",
"choices": [{"index": 0, "message": {"role": "assistant", "content": "The customer wants one of two duplicate charges refunded."}, "finish_reason": "stop"}],
"usage": {"prompt_tokens": 18, "completion_tokens": 12, "total_tokens": 30}
}

The spend log row carries the key, team and user and the cost from usage.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /mistral/...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.
401 from MistralUnauthorizedThe gateway forwarded the call with no usable Mistral key. Add a deployment with Use in pass through routes on, or set MISTRAL_API_KEY.
Any otherMistral's own error bodyMistral refused the request. The message is returned unchanged.

Pass-through endpoints lists every built-in route. The unified chat completions endpoint works with every provider and runs guardrails. The Mistral provider page covers the unified integration.