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.
Chat Completion
Authorizations:
Request Body schema: application/jsonrequired
required | Model (string) or Model (null) (Model) 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. |
temperature | number (Temperature) [ 0 .. 1.5 ] 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 (Top P) [ 0 .. 1 ] Default: 1 Nucleus sampling, where the model considers the results of the tokens with |
Max Tokens (integer) or Max Tokens (null) (Max Tokens) The maximum number of tokens to generate in the completion. The token count of your prompt plus | |
Min Tokens (integer) or Min Tokens (null) (Min Tokens) The minimum number of tokens to generate in the completion. | |
stream | boolean (Stream) Default: false Whether to stream back partial progress. If set, tokens will be sent as data-only server-side 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. |
Stop (string) or Array of Stop (strings) (Stop) Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | |
Random Seed (integer) or Random Seed (null) (Random Seed) The seed to use for random sampling. If set, different calls will generate deterministic results. | |
required | Array of any (Messages) The prompt(s) to generate completions for, encoded as a list of dict with role and content. |
object (ResponseFormat) | |
Array of Tools (objects) or Tools (null) (Tools) | |
tool_choice | string (ToolChoice) Default: "auto" Enum: "auto" "none" "any" |
safe_prompt | boolean Default: false Whether to inject a safety prompt before all conversations. |
Responses
Request samples
- Payload
{- "model": "mistral-small-latest",
- "temperature": 0.7,
- "top_p": 1,
- "max_tokens": 0,
- "min_tokens": 0,
- "stream": false,
- "stop": "string",
- "random_seed": 0,
- "messages": [
- {
- "role": "user",
- "content": "Who is the best French painter? Answer in one short sentence."
}
], - "response_format": {
- "type": "text"
}, - "tools": [
- {
- "type": "function",
- "function": {
- "name": "string",
- "description": "",
- "parameters": { }
}
}
], - "tool_choice": "auto",
- "safe_prompt": false
}
Response samples
- 200
- 422
{- "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
- "object": "chat.completion",
- "model": "mistral-small-latest",
- "usage": {
- "prompt_tokens": 16,
- "completion_tokens": 34,
- "total_tokens": 50
}, - "created": 1702256327,
- "choices": [
- {
- "index": 0,
- "message": {
- "content": "string",
- "tool_calls": [
- {
- "id": "null",
- "type": "function",
- "function": {
- "name": "string",
- "arguments": { }
}
}
], - "prefix": false,
- "role": "assistant"
}, - "finish_reason": "stop"
}
]
}
Fim Completion
FIM completion.
Authorizations:
Request Body schema: application/jsonrequired
required | Model (string) or Model (null) (Model) Default: "codestral-2405" ID of the model to use. Only compatible for now with:
|
temperature | number (Temperature) [ 0 .. 1.5 ] 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 (Top P) [ 0 .. 1 ] Default: 1 Nucleus sampling, where the model considers the results of the tokens with |
Max Tokens (integer) or Max Tokens (null) (Max Tokens) The maximum number of tokens to generate in the completion. The token count of your prompt plus | |
Min Tokens (integer) or Min Tokens (null) (Min Tokens) The minimum number of tokens to generate in the completion. | |
stream | boolean (Stream) Default: false Whether to stream back partial progress. If set, tokens will be sent as data-only server-side 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. |
Stop (string) or Array of Stop (strings) (Stop) Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | |
Random Seed (integer) or Random Seed (null) (Random Seed) The seed to use for random sampling. If set, different calls will generate deterministic results. | |
prompt required | string (Prompt) The text/code to complete. |
Suffix (string) or Suffix (null) (Suffix) Default: "" Optional text/code that adds more context for the model. When given a |
Responses
Request samples
- Payload
{- "model": "codestral-2405",
- "temperature": 0.7,
- "top_p": 1,
- "max_tokens": 0,
- "min_tokens": 0,
- "stream": false,
- "stop": "string",
- "random_seed": 0,
- "prompt": "def",
- "suffix": "return a+b"
}
Response samples
- 200
- 422
{- "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
- "object": "chat.completion",
- "model": "codestral-latest",
- "usage": {
- "prompt_tokens": 16,
- "completion_tokens": 34,
- "total_tokens": 50
}, - "created": 1702256327,
- "choices": [
- {
- "index": 0,
- "message": {
- "content": "string",
- "tool_calls": [
- {
- "id": "null",
- "type": "function",
- "function": {
- "name": "string",
- "arguments": { }
}
}
], - "prefix": false,
- "role": "assistant"
}, - "finish_reason": "stop"
}
]
}
Agents Completion
Authorizations:
Request Body schema: application/jsonrequired
Max Tokens (integer) or Max Tokens (null) (Max Tokens) The maximum number of tokens to generate in the completion. The token count of your prompt plus | |
Min Tokens (integer) or Min Tokens (null) (Min Tokens) The minimum number of tokens to generate in the completion. | |
stream | boolean (Stream) Default: false Whether to stream back partial progress. If set, tokens will be sent as data-only server-side 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. |
Stop (string) or Array of Stop (strings) (Stop) Stop generation if this token is detected. Or if one of these tokens is detected when providing an array | |
Random Seed (integer) or Random Seed (null) (Random Seed) The seed to use for random sampling. If set, different calls will generate deterministic results. | |
required | Array of any (Messages) The prompt(s) to generate completions for, encoded as a list of dict with role and content. |
object (ResponseFormat) | |
Array of Tools (objects) or Tools (null) (Tools) | |
tool_choice | string (ToolChoice) Default: "auto" Enum: "auto" "none" "any" |
agent_id required | string The ID of the agent to use for this completion. |
Responses
Request samples
- Payload
{- "max_tokens": 0,
- "min_tokens": 0,
- "stream": false,
- "stop": "string",
- "random_seed": 0,
- "messages": [
- {
- "role": "user",
- "content": "Who is the best French painter? Answer in one short sentence."
}
], - "response_format": {
- "type": "text"
}, - "tools": [
- {
- "type": "function",
- "function": {
- "name": "string",
- "description": "",
- "parameters": { }
}
}
], - "tool_choice": "auto",
- "agent_id": "string"
}
Response samples
- 200
- 422
{- "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
- "object": "chat.completion",
- "model": "mistral-small-latest",
- "usage": {
- "prompt_tokens": 16,
- "completion_tokens": 34,
- "total_tokens": 50
}, - "created": 1702256327,
- "choices": [
- {
- "index": 0,
- "message": {
- "content": "string",
- "tool_calls": [
- {
- "id": "null",
- "type": "function",
- "function": {
- "name": "string",
- "arguments": { }
}
}
], - "prefix": false,
- "role": "assistant"
}, - "finish_reason": "stop"
}
]
}
Embeddings
Embeddings
Authorizations:
Request Body schema: application/jsonrequired
required | Input (string) or Array of Input (strings) (Input) Text to embed. |
model required | string (Model) ID of the model to use. |
Encoding Format (string) or Encoding Format (null) (Encoding Format) Default: "float" The format to return the embeddings in. |
Responses
Request samples
- Payload
{- "input": "string",
- "model": "string",
- "encoding_format": "float"
}
Response samples
- 200
- 422
{- "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
- "object": "chat.completion",
- "model": "mistral-small-latest",
- "usage": {
- "prompt_tokens": 16,
- "completion_tokens": 34,
- "total_tokens": 50
}, - "data": [
- [
- {
- "object": "embedding",
- "embedding": [
- 0.1,
- 0.2,
- 0.3
], - "index": 0
}, - {
- "object": "embedding",
- "embedding": [
- 0.4,
- 0.5,
- 0.6
], - "index": 1
}
]
]
}
Upload File
Upload a file that can be used across various endpoints.
The size of individual files can be a maximum of 512 MB. The Fine-tuning API only supports .jsonl files.
Please contact us if you need to increase these storage limits.
Authorizations:
Request Body schema: multipart/form-datarequired
purpose | string (Purpose) Default: "fine-tune" Value: "fine-tune" Value: "fine-tune" |
file required | string <binary> (File) The File object (not file name) to be uploaded. To upload a file and specify a custom file name you should format your request as such:
Otherwise, you can just keep the original file name:
|
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f09",
- "object": "file",
- "bytes": 13000,
- "created_at": 1716963433,
- "filename": "files_upload.jsonl",
- "purpose": "fine-tune",
- "sample_type": "pretrain",
- "num_lines": 0,
- "source": "upload"
}
List Files
Returns a list of files that belong to the user's organization.
Authorizations:
Responses
Response samples
- 200
{- "data": [
- {
- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f09",
- "object": "file",
- "bytes": 13000,
- "created_at": 1716963433,
- "filename": "files_upload.jsonl",
- "purpose": "fine-tune",
- "sample_type": "pretrain",
- "num_lines": 0,
- "source": "upload"
}
], - "object": "string"
}
Retrieve File
Returns information about a specific file.
Authorizations:
path Parameters
file_id required | string (File Id) |
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f09",
- "object": "file",
- "bytes": 13000,
- "created_at": 1716963433,
- "filename": "files_upload.jsonl",
- "purpose": "fine-tune",
- "sample_type": "pretrain",
- "num_lines": 0,
- "source": "upload"
}
Get Fine Tuning Jobs
Get a list of fine-tuning jobs for your organization and user.
Authorizations:
query Parameters
page | integer (Page) Default: 0 The page number of the results to be returned. |
page_size | integer (Page Size) Default: 100 The number of items to return per page. |
Model (string) or Model (null) (Model) The model name used for fine-tuning to filter on. When set, the other results are not displayed. | |
Created After (string) or Created After (null) (Created After) The date/time to filter on. When set, the results for previous creation times are not displayed. | |
created_by_me | boolean (Created By Me) Default: false When set, only return results for jobs created by the API caller. Other results are not displayed. |
Status (string) or Status (null) (Status) The current job state to filter on. When set, the other results are not displayed. | |
Wandb Project (string) or Wandb Project (null) (Wandb Project) The Weights and Biases project to filter on. When set, the other results are not displayed. | |
Wandb Name (string) or Wandb Name (null) (Wandb Name) The Weight and Biases run name to filter on. When set, the other results are not displayed. | |
Suffix (string) or Suffix (null) (Suffix) The model suffix to filter on. When set, the other results are not displayed. |
Responses
Response samples
- 200
{- "data": [ ],
- "object": "list",
- "total": 0
}
Create Fine Tuning Job
Create a new fine-tuning job, it will be queued for processing.
Authorizations:
query Parameters
Dry Run (boolean) or Dry Run (null) (Dry Run)
|
Request Body schema: application/jsonrequired
model required | string (FineTuneableModel) Enum: "open-mistral-7b" "mistral-small-latest" "codestral-latest" "mistral-large-latest" "open-mistral-nemo" The name of the model to fine-tune. |
Array of objects (Training Files) Default: [] | |
Array of Validation Files (strings) or Validation Files (null) (Validation Files) A list containing the IDs of uploaded files that contain validation data. If you provide these files, the data is used to generate validation metrics periodically during fine-tuning. These metrics can be viewed in | |
required | object (TrainingParametersIn) The fine-tuning hyperparameter settings used in a fine-tune job. |
Suffix (string) or Suffix (null) (Suffix) A string that will be added to your fine-tuning model name. For example, a suffix of "my-great-model" would produce a model name like | |
Array of Integrations (any) or Integrations (null) (Integrations) A list of integrations to enable for your fine-tuning job. | |
Array of any (Repositories) Default: [] | |
auto_start | boolean (Auto Start) This field will be required in a future release. |
Responses
Request samples
- Payload
{- "model": "open-mistral-7b",
- "training_files": [ ],
- "validation_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001,
- "weight_decay": 0.1,
- "warmup_fraction": 0.05,
- "epochs": 0.01,
- "fim_ratio": 0.9
}, - "suffix": "string",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string",
- "api_key": "stringstringstringstringstringstringstri",
- "run_name": "string"
}
], - "repositories": [ ],
- "auto_start": true
}
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "auto_start": true,
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001,
- "weight_decay": 0.1,
- "warmup_fraction": 0.05,
- "epochs": 0.01,
- "fim_ratio": 0.9
}, - "model": "open-mistral-7b",
- "status": "QUEUED",
- "job_type": "string",
- "created_at": 0,
- "modified_at": 0,
- "training_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "validation_files": [ ],
- "object": "job",
- "fine_tuned_model": "string",
- "suffix": "string",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string",
- "run_name": "string"
}
], - "trained_tokens": 0,
- "repositories": [ ],
- "metadata": {
- "expected_duration_seconds": 0,
- "cost": 0,
- "cost_currency": "string",
- "train_tokens_per_step": 0,
- "train_tokens": 0,
- "data_tokens": 0,
- "estimated_start_time": 0
}
}
Get Fine Tuning Job
Get a fine-tuned job details by its UUID.
Authorizations:
path Parameters
job_id required | string <uuid> (Job Id) The ID of the job to analyse. |
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "auto_start": true,
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001,
- "weight_decay": 0.1,
- "warmup_fraction": 0.05,
- "epochs": 0.01,
- "fim_ratio": 0.9
}, - "model": "open-mistral-7b",
- "status": "QUEUED",
- "job_type": "string",
- "created_at": 0,
- "modified_at": 0,
- "training_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "validation_files": [ ],
- "object": "job",
- "fine_tuned_model": "string",
- "suffix": "string",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string",
- "run_name": "string"
}
], - "trained_tokens": 0,
- "repositories": [ ],
- "metadata": {
- "expected_duration_seconds": 0,
- "cost": 0,
- "cost_currency": "string",
- "train_tokens_per_step": 0,
- "train_tokens": 0,
- "data_tokens": 0,
- "estimated_start_time": 0
}, - "events": [ ],
- "checkpoints": [ ]
}
Cancel Fine Tuning Job
Request the cancellation of a fine tuning job.
Authorizations:
path Parameters
job_id required | string <uuid> (Job Id) The ID of the job to cancel. |
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "auto_start": true,
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001,
- "weight_decay": 0.1,
- "warmup_fraction": 0.05,
- "epochs": 0.01,
- "fim_ratio": 0.9
}, - "model": "open-mistral-7b",
- "status": "QUEUED",
- "job_type": "string",
- "created_at": 0,
- "modified_at": 0,
- "training_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "validation_files": [ ],
- "object": "job",
- "fine_tuned_model": "string",
- "suffix": "string",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string",
- "run_name": "string"
}
], - "trained_tokens": 0,
- "repositories": [ ],
- "metadata": {
- "expected_duration_seconds": 0,
- "cost": 0,
- "cost_currency": "string",
- "train_tokens_per_step": 0,
- "train_tokens": 0,
- "data_tokens": 0,
- "estimated_start_time": 0
}, - "events": [ ],
- "checkpoints": [ ]
}
Start Fine Tuning Job
Request the start of a validated fine tuning job.
Authorizations:
path Parameters
job_id required | string <uuid> (Job Id) |
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "auto_start": true,
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001,
- "weight_decay": 0.1,
- "warmup_fraction": 0.05,
- "epochs": 0.01,
- "fim_ratio": 0.9
}, - "model": "open-mistral-7b",
- "status": "QUEUED",
- "job_type": "string",
- "created_at": 0,
- "modified_at": 0,
- "training_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "validation_files": [ ],
- "object": "job",
- "fine_tuned_model": "string",
- "suffix": "string",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string",
- "run_name": "string"
}
], - "trained_tokens": 0,
- "repositories": [ ],
- "metadata": {
- "expected_duration_seconds": 0,
- "cost": 0,
- "cost_currency": "string",
- "train_tokens_per_step": 0,
- "train_tokens": 0,
- "data_tokens": 0,
- "estimated_start_time": 0
}, - "events": [ ],
- "checkpoints": [ ]
}
Response samples
- 200
- 422
{- "object": "list",
- "data": [
- {
- "id": "string",
- "object": "model",
- "created": 0,
- "owned_by": "mistralai",
- "root": "string",
- "archived": false,
- "name": "string",
- "description": "string",
- "capabilities": {
- "completion_chat": true,
- "completion_fim": false,
- "function_calling": true,
- "fine_tuning": false
}, - "max_context_length": 32768,
- "aliases": [ ],
- "deprecation": "2019-08-24T14:15:22Z"
}
]
}
Retrieve Model
Retrieve a model information.
Authorizations:
path Parameters
model_id required | string (Model Id) Example: ft:open-mistral-7b:587a6b29:20240514:7e773925 The ID of the model to retrieve. |
Responses
Response samples
- 200
- 422
{- "id": "string",
- "object": "model",
- "created": 0,
- "owned_by": "mistralai",
- "root": "string",
- "archived": false,
- "name": "string",
- "description": "string",
- "capabilities": {
- "completion_chat": true,
- "completion_fim": false,
- "function_calling": true,
- "fine_tuning": false
}, - "max_context_length": 32768,
- "aliases": [ ],
- "deprecation": "2019-08-24T14:15:22Z"
}
Delete Model
Delete a fine-tuned model.
Authorizations:
path Parameters
model_id required | string (Model Id) Example: ft:open-mistral-7b:587a6b29:20240514:7e773925 The ID of the model to delete. |
Responses
Response samples
- 200
- 422
{- "id": "ft:open-mistral-7b:587a6b29:20240514:7e773925",
- "object": "model",
- "deleted": true
}
Update Fine Tuned Model
Update a model name or description.
Authorizations:
path Parameters
model_id required | string (Model Id) Example: ft:open-mistral-7b:587a6b29:20240514:7e773925 The ID of the model to update. |
Request Body schema: application/jsonrequired
Name (string) or Name (null) (Name) | |
Description (string) or Description (null) (Description) |
Responses
Request samples
- Payload
{- "name": "string",
- "description": "string"
}
Response samples
- 200
{- "id": "string",
- "object": "model",
- "created": 0,
- "owned_by": "string",
- "root": "string",
- "archived": true,
- "name": "string",
- "description": "string",
- "capabilities": {
- "completion_chat": true,
- "completion_fim": false,
- "function_calling": false,
- "fine_tuning": false
}, - "max_context_length": 32768,
- "aliases": [ ],
- "job": "4bbaedb0-902b-4b27-8218-8f40d3470a54"
}
Archive Fine Tuned Model
Archive a fine-tuned model.
Authorizations:
path Parameters
model_id required | string (Model Id) Example: ft:open-mistral-7b:587a6b29:20240514:7e773925 The ID of the model to archive. |
Responses
Response samples
- 200
{- "id": "string",
- "object": "model",
- "archived": true
}
Unarchive Fine Tuned Model
Un-archive a fine-tuned model.
Authorizations:
path Parameters
model_id required | string (Model Id) Example: ft:open-mistral-7b:587a6b29:20240514:7e773925 The ID of the model to unarchive. |
Responses
Response samples
- 200
{- "id": "string",
- "object": "model",
- "archived": false
}