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
Authorizations:
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. |
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 FIM Completions
Authorizations:
Request Body schema: application/jsonrequired
prompt required | string The text/code to complete. |
suffix | string or null Optional text/code that adds more context for the model.
When given a |
model required | string or null ID of the model to use. Only compatible for now with:
|
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 outptu 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 with We generally recommend altering this or |
max_tokens | integer or null >= 0 The maximum number of tokens to generate in the completion. The token count of your prompt plus |
min_tokens | integer or null >= 0 The minimum number of tokens to generate in the completion. |
stream | boolean 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. |
random_seed | integer or null >= 0 The seed to use for random sampling. If set, different calls will generate deterministic results. |
string or Array of strings Default: [] |
Responses
Request samples
- Payload
{- "prompt": "def",
- "suffix": "return a+b",
- "model": "codestral-latest",
- "temperature": 0,
- "top_p": 1,
- "max_tokens": 1024,
- "min_tokens": 0,
- "stream": false,
- "random_seed": 1337,
- "stop": [ ]
}
Response samples
- 200
{- "id": "5b35cc2e69bf4ba9a11373ee1f1937f8",
- "object": "chat.completion",
- "created": 1702256327,
- "model": "codestral-latest",
- "choices": [
- {
- "index": 0,
- "message": {
- "role": "assistant",
- "content": "\" add(a,b):\""
}, - "finish_reason": "stop"
}
], - "usage": {
- "prompt_tokens": 8,
- "completion_tokens": 9,
- "total_tokens": 17
}
}
Create Embeddings
Authorizations:
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
}
}
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 required | any (Purpose) The intended purpose of the uploaded file. Only accepts fine-tuning ( 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-53cbbbba6f08",
- "object": "file",
- "bytes": 12000,
- "created_at": 1717491627,
- "filename": "train.jsonl",
- "purpose": "fine-tune"
}
List Files
Returns a list of files that belong to the user's organization.
Authorizations:
Responses
Response samples
- 200
{- "data": [
- {
- "id": "d56b5e4f-16ae-4f07-be8e-b837aa10240f",
- "object": "file",
- "bytes": 1534119,
- "created_at": 1716329302,
- "filename": "file_upload.jsonl",
- "purpose": "fine-tune"
}
], - "object": "string"
}
Retrieve File
Returns information about a specific file.
Authorizations:
path Parameters
file_id required | string (File Id) The ID of the file to use for this request. |
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "object": "string",
- "bytes": 0,
- "created_at": 0,
- "filename": "string",
- "purpose": "fine-tune"
}
List 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 (Model) The model name used for fine-tuning to filter on. When set, the other results are not displayed. |
status | string (Status) Enum: "QUEUED" "STARTED" "RUNNING" "FAILED" "SUCCESS" "CANCELLED" "CANCELLATION_REQUESTED" The current job state to filter on. When set, the other results are not displayed. |
created_after | string or null <datetime> The date/time to filter on. When set, the results for previous creation times are not displayed. |
created_by_me | bool Default: false When set, only return results for jobs created by the API caller. Other results are not displayed. |
wandb_project | string or null The Weights and Biases project to filter on. When set, the other results are not displayed. |
wandb_name | string or null The Weight and Biases run name to filter on. When set, the other results are not displayed. |
suffix | string or null The model suffix to filter on. When set, the other results are not displayed. |
Responses
Response samples
- 200
{- "data": [ ],
- "object": "list"
}
Create Fine Tuning Job
Create a new fine tuning job, it will be queued for processing.
Authorizations:
query Parameters
dry_run | bool Default: false
|
Request Body schema: application/jsonrequired
model required | string (FineTuneableModel) Enum: "open-mistral-7b" "mistral-small-latest" The name of the model to fine-tune. |
training_files required | Array of strings <uuid> (Training Files) non-empty [ items <uuid > ] A list containing the IDs of uploaded files that contain training data. |
validation_files | Array of strings <uuid> (Validation Files) [ items <uuid > ] 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 The same data should not be present in both train and validation files. |
required | object (TrainingParameters) The fine-tuning hyperparameter settings used in a fine-tune job. |
suffix | string (Suffix) <= 18 characters 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 objects (Integrations) unique A list of integrations to enable for your fine-tuning job. |
Responses
Request samples
- Payload
{- "model": "open-mistral-7b",
- "training_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "validation_files": [
- "497f6eca-6276-4993-bfeb-53cbbbba6f08"
], - "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001
}, - "suffix": "string",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string",
- "api_key": "string"
}
]
}
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001
}, - "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",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string"
}
]
}
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",
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001
}, - "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",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string"
}
], - "events": [ ],
- "checkpoints": [ ]
}
Cancel Fine Tuning Job
Request the cancellation of a fine tuning job.
Authorizations:
path Parameters
job_id required | string <uuid> (Job Id) |
Responses
Response samples
- 200
{- "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
- "hyperparameters": {
- "training_steps": 1,
- "learning_rate": 0.0001
}, - "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",
- "integrations": [
- {
- "type": "wandb",
- "project": "string",
- "name": "string"
}
], - "events": [ ],
- "checkpoints": [ ]
}