Skip to main content

Mistral AI

Connect AISIX AI Gateway to Mistral AI so applications can call Mistral models through the gateway's OpenAI-compatible API. AISIX keeps the Mistral credential on the gateway side. It authorizes model access with caller API keys and allowlists, and applies the same rate-limit and usage-accounting controls as other model aliases.

Mistral exposes an OpenAI-compatible API, so it uses the openai adapter with a Mistral api_base.

Prerequisites

The following examples use a self-hosted AISIX gateway. Before configuring the upstream, prepare the following:

Configure the Mistral Upstream

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

Create a Provider Key

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

# Replace with your values
export AISIX_ADMIN_KEY="YOUR_ADMIN_KEY"
export MISTRAL_API_KEY="YOUR_PROVIDER_API_KEY"

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/provider_keys" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"display_name": "mistral-prod",
"provider": "mistral",
"adapter": "openai",
"secret": "'"${MISTRAL_API_KEY}"'",
"api_base": "https://api.mistral.ai/v1"
}'

provider is mistral.

adapter is openai, because Mistral accepts OpenAI chat-completions requests.

secret stores the Mistral API key. It follows the credential-handling behavior in Provider Credentials.

api_base is required and already includes the /v1 path. AISIX appends /chat/completions to it.

Copy the returned provider key ID.

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.

Create the model alias callers will send in requests:

# Replace with your values
export PROVIDER_KEY_ID="YOUR_PROVIDER_KEY_ID"

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/models" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"display_name": "mistral-large-prod",
"provider": "mistral",
"model_name": "mistral-large-latest",
"provider_key_id": "'"${PROVIDER_KEY_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.

provider_key_id attaches the alias to the Mistral provider key.

Create a Caller API Key

Choose the caller API key value that the application will send to AISIX, then hash it for the admin resource:

# Replace with your values
export AISIX_API_KEY="YOUR_CALLER_API_KEY"

CALLER_KEY_HASH=$(printf '%s' "${AISIX_API_KEY}" | shasum -a 256 | awk '{print $1}')

Create the caller API key resource that can access the model alias:

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/apikeys" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"key_hash": "'"${CALLER_KEY_HASH}"'",
"allowed_models": ["mistral-large-prod"]
}'

The allowed_models value must match the model alias you created.

Verify the Provider Connection

Send a chat-completions request through the AISIX proxy:

curl -sS -X POST "http://127.0.0.1:3000/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 secret, api_base, and the Mistral model ID in model_name.

Next Steps

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

API7.ai Logo

The digital world is connected by APIs,
API7.ai exists to make APIs more efficient, reliable, and secure.

Sign up for API7 newsletter

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2026. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the Apache Software Foundation