Tree BG 1
Tree
Tree
TreeLeaves
TreeLeaves
Cat IdleGrassGrassRockRock

Chat Endpoints

Chat Completion API.

Chat Completion

POST /v1/chat/completions

200 (application/json)

200 (text/event-stream)

Successful Response

created
*integer
id
*string
model
*string
object
*string
usage
*UsageInfo

Playground

Test the endpoints live

import { Mistral } from "@mistralai/mistralai";

const mistral = new Mistral({
  apiKey: "MISTRAL_API_KEY",
});

async function run() {
  const result = await mistral.chat.complete({
    model: "mistral-small-latest",
    messages: [
      {
        content: "Who is the best French painter? Answer in one short sentence.",
        role: "user",
      },
    ],
  });

  console.log(result);
}

run();
from mistralai import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.chat.complete(model="mistral-small-latest", messages=[
        {
            "content": "Who is the best French painter? Answer in one short sentence.",
            "role": "user",
        },
    ], stream=False)

    # Handle response
    print(res)

curl https://api.mistral.ai/v1/chat/completions \
 -X POST \
 -H 'Authorization: Bearer YOUR_APIKEY_HERE' \
 -d '{
  "messages": [
    {
      "content": "ipsum eiusmod"
    }
  ],
  "model": "mistral-large-latest"
}'

200 (application/json)

200 (text/event-stream)

{
  "choices": [
    {
      "finish_reason": "stop",
      "index": "0",
      "message": {}
    }
  ],
  "created": "1702256327",
  "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
  "model": "mistral-small-latest",
  "object": "chat.completion",
  "usage": {}
}