Mistral AI API (0.0.2)
Download OpenAPI specification:Download
Our Chat Completion and Embeddings APIs specification. Create your account on La Plateforme to get access and read the docs to learn how to use it.
Create Chat Completions
Request Body schema: application/jsonrequired
model required | string ID of the model to use. You can use the List Available Models API to see all of your available models, or see our Model overview for model descriptions. |
required | Array of objects The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be |
temperature | number or null [ 0 .. 1 ] Default: 0.7 What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or |
top_p | number or null [ 0 .. 1 ] Default: 1 Nucleus sampling, where the model considers the results of the tokens with We generally recommend altering this or |
max_tokens | integer or null >= 0 Default: null The maximum number of tokens to generate in the completion. The token count of your prompt plus |
stream | boolean or null Default: false Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON. |
safe_prompt | boolean Default: false Whether to inject a safety prompt before all conversations. |
random_seed | integer Default: null The seed to use for random sampling. If set, different calls will generate deterministic results. |
Responses
Request samples
- Payload
{- "model": "mistral-small-latest",
- "messages": [
- {
- "role": "user",
- "content": "Who is the best French painter? Answer in one short sentence."
}
], - "temperature": 0.7,
- "top_p": 1,
- "max_tokens": 512,
- "stream": false,
- "safe_prompt": false,
- "random_seed": 1337
}
Response samples
- 200
{- "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
- "object": "chat.completion",
- "created": 1702256327,
- "model": "mistral-small-latest",
- "choices": [
- {
- "index": 0,
- "message": {
- "role": "assistant",
- "content": "Claude Monet is often considered one of the best French painters due to his significant role in the Impressionist movement."
}, - "finish_reason": "stop"
}
], - "usage": {
- "prompt_tokens": 16,
- "completion_tokens": 34,
- "total_tokens": 50
}
}
Create Embeddings
Request Body schema: application/jsonrequired
model | string The ID of the model to use for this request. |
input | Array of strings The list of strings to embed. |
encoding_format | string Value: "float" The format of the output data. |
Responses
Request samples
- Payload
{- "model": "mistral-embed",
- "input": [
- "Hello",
- "world"
], - "encoding_format": "float"
}
Response samples
- 200
{- "id": "embd-aad6fc62b17349b192ef09225058bc45",
- "object": "list",
- "data": [
- {
- "object": "embedding",
- "embedding": [
- 0.1,
- 0.2,
- 0.3
], - "index": 0
}, - {
- "object": "embedding",
- "embedding": [
- 0.4,
- 0.5,
- 0.6
], - "index": 1
}
], - "model": "string",
- "usage": {
- "prompt_tokens": 9,
- "total_tokens": 9
}
}