# Mistral AI

[Mistral AI](https://docs.mistral.ai/) develops and hosts the Mistral family of models. AISIX lets applications call its chat and compatible API surfaces with gateway-issued caller keys.

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Before starting, prepare the following:

* One AISIX setup:

  <!-- -->

  * For AISIX Enterprise or AISIX Cloud, an environment with an attached gateway and a write-scoped admin token. For AISIX Enterprise, follow the [AISIX Enterprise getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/aisix-cloud-quickstart.md). To request AISIX Cloud access, [contact API7](https://api7.ai/contact).
  * For the open-source AISIX gateway, prepare either a local AISIX installation or the Docker setup from the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Configure the gateway to load a declarative resources file.

* A Mistral API key from the [Mistral console](https://console.mistral.ai/api-keys).

* `curl` and `jq`.

## Configure with AISIX Enterprise or AISIX Cloud[​](#configure-with-aisix-enterprise-or-aisix-cloud "Direct link to Configure with AISIX Enterprise or AISIX Cloud")

Export the control-plane connection details:

```
# AISIX_CP is the Admin API base URL; include /api and omit a trailing slash

# The local AISIX Enterprise quickstart uses http://localhost:8080/api

export AISIX_CP="YOUR_AISIX_CONTROL_PLANE_API_URL"

export AISIX_TOKEN="YOUR_ADMIN_TOKEN"

export ENV_ID="YOUR_ENVIRONMENT_ID"
```

Create a provider key, model alias, and caller API key for the Mistral-backed chat-completions route.

Because Mistral exposes an OpenAI-compatible API, AISIX connects through the `openai` adapter and uses the Mistral API root as `api_base`.

### Create a Provider Key[​](#create-a-provider-key "Direct link to Create a Provider Key")

Create the provider key that stores the Mistral credential and API root:

```
# Replace with your value

export MISTRAL_API_KEY="YOUR_PROVIDER_API_KEY"



PROVIDER_KEY_ID=$(curl -sS -X POST "$AISIX_CP/provider_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "mistral-prod",

    "provider": "mistral",

    "api_key": "'"${MISTRAL_API_KEY}"'",

    "api_base": "https://api.mistral.ai/v1",

    "allowed_environments": ["'"${ENV_ID}"'"]

  }' | jq -r '.provider_key.id')



echo "$PROVIDER_KEY_ID"
```

❶ `provider` is `mistral`. The AISIX Cloud Admin API derives the adapter from the catalog provider; the adapter field is only accepted on BYO provider keys.

❷ `api_key` stores the Mistral API key. It follows the credential-handling behavior in [Provider Keys](https://docs.api7.ai/ai-gateway/models/provider-keys.md#credential-handling).

❸ `api_base` already includes the `/v1` path. AISIX appends `/chat/completions` to it. The field is optional for this catalog provider, because the AISIX Cloud Admin API fills in this same value when you omit it, but the examples set it explicitly so the upstream root stays visible on the resource.

The command captures the returned provider key ID in `PROVIDER_KEY_ID`.

### Create a Model[​](#create-a-model "Direct link to Create a Model")

Mistral model IDs ending in `-latest` track the newest snapshot of that model. To pin a specific version, use the dated model ID from the [Mistral models list](https://docs.mistral.ai/models/overview).

Create the model alias callers will send in requests:

```
MODEL_ID=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/models" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "mistral-large-prod",

    "model_name": "mistral-large-latest",

    "provider_key_id": "'"${PROVIDER_KEY_ID}"'"

  }' | jq -r '.model.id')



echo "$MODEL_ID"
```

❶ `display_name` is the alias callers send in `model`.

❷ `model_name` is the Mistral model ID, for example `mistral-large-latest` or `mistral-small-latest`. If you use structured reasoning with `mistral-small-latest`, review [Understand Structured Responses](#understand-structured-responses) before enabling it.

❸ `provider_key_id` attaches the alias to the Mistral provider key.

### Create a Caller API Key[​](#create-a-caller-api-key "Direct link to Create a Caller API Key")

Create the caller API key that can access the model alias. The plaintext key is server-generated and returned once in the response — store it securely:

```
AISIX_API_KEY=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/api_keys" \

  -H "Authorization: Bearer $AISIX_TOKEN" \

  -H "Content-Type: application/json" \

  -d '{

    "display_name": "mistral-caller",

    "allowed_models": ["'"${MODEL_ID}"'"]

  }' | jq -r '.plaintext')



echo "$AISIX_API_KEY"
```

The `allowed_models` value must reference the model ID captured in the previous step.

The gateway picks up the new resources automatically — no restart is needed.

## Configure with AISIX OSS[​](#configure-with-aisix-oss "Direct link to Configure with AISIX OSS")

Export the upstream credential and choose the caller API key that applications will send to the gateway:

```
export MISTRAL_API_KEY="YOUR_PROVIDER_API_KEY"

export CALLER_API_KEY="YOUR_CALLER_API_KEY"

export CALLER_API_KEY_SHA256="$(printf '%s' "$CALLER_API_KEY" | sha256sum | cut -d ' ' -f 1)"
```

For a new gateway, use this complete resources file. For an existing gateway, merge the entries into its [current file](https://docs.api7.ai/ai-gateway/reference/resources-file.md#apply-resource-examples-safely), preserving its other resources:

resources.yaml

```
_format_version: "2"



provider_keys:

  - id: 25fb8f6b-f5c4-43aa-96fc-bbba61cc4ca8

    display_name: "mistral-prod"

    provider: "mistral"

    adapter: "openai"

    api_key: ${MISTRAL_API_KEY}

    api_base: "https://api.mistral.ai/v1"



models:

  - id: f99309c4-563d-455d-8304-f415391d421e

    display_name: "mistral-large-prod"

    provider: "mistral"

    model_name: "mistral-large-latest"

    provider_key_id: 25fb8f6b-f5c4-43aa-96fc-bbba61cc4ca8



api_keys:

  - id: 023cac2b-a98f-406a-922d-d74cc9fb2aec

    display_name: "mistral-caller"

    key_hash: ${CALLER_API_KEY_SHA256}

    allowed_models:

      - "mistral-large-prod"
```

If AISIX is installed locally, validate the file before loading it:

```
aisix validate --resources resources.yaml
```

After validation, start the gateway with the referenced environment variables in its process environment. Reload an existing gateway only if those variables are already available to the process; otherwise, restart it with the updated environment.

If you use Docker, adapt the validation and startup commands in the [AISIX OSS getting-started guide](https://docs.api7.ai/ai-gateway/getting-started/gateway-quickstart.md). Mount this `resources.yaml` file and pass every environment variable it references with `-e` in both commands. After the resources load, prepare the shared verification request below:

```
export AISIX_API_KEY="$CALLER_API_KEY"
```

## Verify the Provider Connection[​](#verify-the-provider-connection "Direct link to Verify the Provider Connection")

Export the AISIX gateway origin:

```
# AISIX_PROXY has no trailing slash or endpoint path

# The local quickstarts use http://127.0.0.1:3000

export AISIX_PROXY="YOUR_AISIX_GATEWAY_URL"
```

Send a chat-completions request through the AISIX proxy:

```
curl -sS -X POST "$AISIX_PROXY/v1/chat/completions" \

  -H "Authorization: Bearer ${AISIX_API_KEY}" \

  -H "Content-Type: application/json" \

  -d '{

    "model": "mistral-large-prod",

    "messages": [

      {

        "role": "user",

        "content": "Say hello from Mistral."

      }

    ]

  }'
```

The gateway returns an OpenAI-compatible response that echoes the caller-facing alias `mistral-large-prod`. If the request fails, check the provider key `api_key`, `api_base`, and the Mistral model ID in `model_name`.

## Understand Structured Responses[​](#understand-structured-responses "Direct link to Understand Structured Responses")

Standard Mistral chat responses work through the normalized AISIX endpoints when `message.content`, or each streaming `delta.content`, is a string. Text and OpenAI-style image input blocks are forwarded to compatible multimodal models such as Mistral Large 3.

Current Mistral reasoning models can return a different shape. With `reasoning_effort: "high"`, Mistral returns arrays of `ThinkChunk` and `TextChunk` objects in `content`. A non-streaming response reaches each normalized endpoint as follows:

* `/v1/chat/completions` returns the array in `message.content` as Mistral sent it. AISIX does not convert the thinking chunks to `reasoning_content`.
* `/v1/messages` returns the text as a `text` block and the thinking chunks as a `thinking` block with `signature: ""`, as described in [Anthropic Messages](https://docs.api7.ai/ai-gateway/endpoints/anthropic-messages.md).
* `/v1/responses` returns the text as `output_text` and the thinking chunks as a `reasoning` output item, as described in [Responses API](https://docs.api7.ai/ai-gateway/endpoints/responses-api.md).

The thinking text is also captured as reasoning by content exporters, and counted in the estimated completion tokens when Mistral reports no usage. A `response.reasoning_field` override cannot convert the content array.

A stream whose `delta.content` is such an array keeps the order of its chunks on every endpoint. `/v1/chat/completions` returns the text of the `text` chunks as `delta.content` and the thinking chunks as `delta.reasoning_content`, so a streamed answer has a different shape from a non-streaming one. A chat delta has no field for the chunk's `signature`, so the signature is not returned. `/v1/messages` streams the thinking as a `thinking` block, and `/v1/responses` streams it as a `reasoning` item. Content exporters and the estimated completion tokens count the streamed thinking the same way as a non-streaming answer's.

A Mistral thinking chunk replayed in an assistant turn on `/v1/chat/completions` is checked by input guardrails. See [Reasoning and Thinking Content](https://docs.api7.ai/ai-gateway/traffic-controls/guardrails/content-coverage.md#reasoning-and-thinking-content).

For a reasoning-capable model such as `mistral-small-latest`, use `reasoning_effort: "none"` on the normalized endpoints when you do not need its reasoning. To receive the thinking chunks exactly as Mistral sent them, including on a stream, call Mistral's native chat contract through `/passthrough/mistral/chat/completions` and send the upstream Mistral model ID rather than the AISIX alias. The `/passthrough/mistral` paths on this page assume a [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) claiming that prefix with the Mistral API root as its `target_url`; grant the route name on the caller key's `allowed_routes`. The route preserves the response body and relays a native streaming response incrementally.

Mistral also supports `n` greater than `1`. `/v1/chat/completions` returns every choice, while `/v1/messages` and `/v1/responses` carry one answer and return the first. See [The Whole Answer Comes Back](https://docs.api7.ai/ai-gateway/endpoints/request-parameters.md#the-whole-answer-comes-back).

## Endpoint Coverage[​](#endpoint-coverage "Direct link to Endpoint Coverage")

The model alias in this guide is a chat model. Create a separate alias with the appropriate Mistral model ID for embeddings, transcription, speech, or another capability.

| Route                      | Behavior with a Mistral alias                                                                                                                                                                                                                                                                                                                       |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/v1/chat/completions`     | Supported, including `stream: true`, function tools, and text or image input supported by the selected model. A non-streaming structured reasoning response is returned as Mistral sent it; a stream returns its thinking as `delta.reasoning_content`.                                                                                             |
| `/v1/responses`            | Supported through the [Responses bridge](https://docs.api7.ai/ai-gateway/endpoints/responses-api.md), which translates to chat completions rather than calling a native Mistral Responses API. Fields without a chat equivalent are ignored. A structured reasoning response, streamed or not, returns its thinking as a `reasoning` item.          |
| `/v1/messages`             | Supported for Anthropic-shaped callers through translation to chat completions. A structured reasoning response, streamed or not, returns its thinking as a `thinking` block. The alias is OpenAI-backed, so `/v1/messages/count_tokens` returns a 400 error.                                                                                       |
| `/v1/embeddings`           | Supported with a dedicated alias such as `mistral-embed`. AISIX forwards `dimensions`, but Mistral names the reduced-size field `output_dimension`; configure a request parameter rename if you need it.                                                                                                                                            |
| `/v1/audio/transcriptions` | Supported with a transcription alias such as `voxtral-mini-latest`. AISIX relays the Mistral response, including provider-specific fields, but buffers streaming responses rather than relaying their events incrementally.                                                                                                                         |
| `/v1/audio/translations`   | Not supported because Mistral does not publish this route.                                                                                                                                                                                                                                                                                          |
| `/v1/audio/speech`         | The path reaches Mistral TTS, but the wire contract is not OpenAI-compatible. Send native fields such as `voice_id` and expect base64 JSON, or a buffered Mistral SSE payload, rather than raw audio bytes. AISIX does not translate this contract.                                                                                                 |
| `/v1/files`                | Supported for upload, list, retrieve, delete, and content download. Mistral's signed-URL route at `/v1/files/{id}/url` is reachable through a passthrough route, but it requires a raw Mistral file ID. A passthrough route does not decode the AISIX-routed ID returned by a normalized upload.                                                    |
| `/v1/batches`              | Not supported. AISIX forwards the OpenAI `/v1/batches` path, while Mistral uses `/v1/batch/jobs`.                                                                                                                                                                                                                                                   |
| `/v1/fine_tuning/jobs`     | Not supported. AISIX forwards the OpenAI job surface and requires `training_file`; Mistral's current public API does not publish compatible fine-tuning job routes.                                                                                                                                                                                 |
| `/v1/completions`          | Not supported. Mistral code completion uses the native `/v1/fim/completions` contract.                                                                                                                                                                                                                                                              |
| `/v1/images/generations`   | Rejected with a 400 error because the route accepts only models whose provider is `openai` or whose provider key uses the `azure-openai` adapter (see [Provider Requirement](https://docs.api7.ai/ai-gateway/endpoints/image-generation.md#provider-requirement)). Mistral image generation is a built-in tool rather than this OpenAI image route. |
| `/v1/rerank`               | Rejected with a 400 error because the route does not accept the `mistral` provider. Mistral publishes classification APIs, not this rerank contract.                                                                                                                                                                                                |
| `/passthrough/mistral/*`   | Available through a configured [passthrough route](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md) for native Mistral routes, with raw request and response bodies. Provider SSE responses relay incrementally.                                                                                                                  |

Passthrough routes are the way to reach Mistral-native OCR, moderation, classification, FIM, batch, Agents, Conversations, and structured reasoning. For example, with a route targeting `https://api.mistral.ai/v1`, `/passthrough/mistral/ocr` and `/passthrough/mistral/v1/ocr` both resolve to `https://api.mistral.ai/v1/ocr`, because AISIX removes one duplicated version segment.

AISIX does not rewrite a `model` value in a passthrough body. The route supplies the upstream base URL and, in inject mode, the provider key credential; a route binds one target and credential, so configure separate routes for separate Mistral accounts or bases. For the request shapes that record token usage, see [Envelope Detection and Usage](https://docs.api7.ai/ai-gateway/endpoints/provider-passthrough.md#envelope-detection-and-token-usage).

## Next Steps[​](#next-steps "Direct link to Next Steps")

You have now connected AISIX to Mistral and verified the model alias. Continue with these guides:

* [Model Aliases](https://docs.api7.ai/ai-gateway/models/model-aliases.md): configure routing, retry behavior, or cost metadata for this alias.
* [Routing and Failover](https://docs.api7.ai/ai-gateway/routing/routing-and-failover.md): fail over between Mistral and a second provider.
* [Provider-Specific Overrides](https://docs.api7.ai/ai-gateway/models/provider-keys.md#configure-provider-specific-overrides): adapt request and response shapes when an upstream API differs from its adapter.
* [Provider Compatibility](https://docs.api7.ai/ai-gateway/providers/compatibility.md): review supported proxy endpoints and provider-specific boundaries.
