Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Setup guide - Documented by OpenCode

Use Mistral in OpenCode

OpenCode's provider docs have no dedicated Mistral section, but they document a Custom provider for any OpenAI-compatible API using @ai-sdk/openai-compatible. Mistral documents its OpenAI-compatible base URL, https://api.mistral.ai/v1. Combine the two: store the key with /connect > Other, then declare the provider and Mistral model ids in opencode.json.

Last verified 4 steps4 official sources

Steps

  1. Step 1.

    Run /connect, scroll down to Other, enter a unique provider id (the docs say you will reuse it in your config file), then paste your Mistral API key.

    Terminal
    $ /connect
    
    ┌  Add credential
    │
    ◆  Select provider
    │  ...
    │  ● Other
    └
  2. Step 2.

    Create or update opencode.json in your project directory. This is the docs' custom-provider template with Mistral's documented base URL and model ids filled in. The provider id must match the one you entered in /connect.

    JSON
    {
      "$schema": "https://opencode.ai/config.json",
      "provider": {
        "mistral-api": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Mistral",
          "options": {
            "baseURL": "https://api.mistral.ai/v1"
          },
          "models": {
            "mistral-medium-latest": {
              "name": "Mistral Medium 3.5"
            },
            "codestral-latest": {
              "name": "Codestral"
            }
          }
        }
      }
    }
  3. Step 3.

    Optionally load the key from an environment variable instead of /connect, using the docs' {env:...} syntax for options.apiKey.

    JSON
    "apiKey": "{env:MISTRAL_API_KEY}"
  4. Step 4.

    Run /models. Your custom provider and its models appear in the selection list.

    Snippet
    /models

Caveats

  • This combines OpenCode's documented Custom provider config with the base URL from Mistral's migration guide and model ids from Mistral's Models Overview. OpenCode's docs do not show Mistral specifically.
  • The provider id mistral-api is an example name chosen here. The docs only require a unique id that matches the one entered in /connect.
  • OpenCode says it supports 75+ providers through Models.dev, so Mistral may also appear directly in /connect. The providers page has no Mistral section to confirm that.
  • Per OpenCode's docs, @ai-sdk/openai-compatible targets /v1/chat/completions, which is the endpoint Mistral documents.
  • Mistral Medium 3.5 has a 256k context window per Mistral's docs. Standard providers pull limits from models.dev; for a custom provider, set limit.context and limit.output yourself if you need OpenCode to track context.
  • Devstral 2 (devstral-2512, devstral-latest) was retired 2026-07-31 and replaced by mistral-medium-3-5.

FAQ

How do I use Mistral in OpenCode?

OpenCode's provider docs have no dedicated Mistral section, but they document a Custom provider for any OpenAI-compatible API using @ai-sdk/openai-compatible. Mistral documents its OpenAI-compatible base URL, https://api.mistral.ai/v1. Combine the two: store the key with /connect > Other, then declare the provider and Mistral model ids in opencode.json.

Which Mistral model ids work in OpenCode?

The official docs read for this guide list mistral-medium-3-5, mistral-medium-latest, mistral-small-2603, mistral-small-latest, codestral-2508 and codestral-latest. Requests go to https://api.mistral.ai/v1.

Is this an official Mistral and OpenCode setup?

OpenCode documents this setup in its own docs. It was last checked against 4 official pages on October 17, 2026.

Sources

Last verified against 4 official pages.

Newsletter

New models, set up the day they ship

One email per week. New model releases, the coding tools that support them and how to wire them up.