Skip to main content

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:
ApiKeyAuth
Request Body schema: application/json
required
Any of
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 but not both.

top_p
number or null [ 0 .. 1 ]
Default: 1

Nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

We generally recommend altering this or temperature but not both.

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 max_tokens cannot exceed the model's context length.

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

Content type
application/json
Example
{
  • "model": "mistral-small-latest",
  • "messages": [
    ],
  • "temperature": 0.7,
  • "top_p": 1,
  • "max_tokens": 512,
  • "stream": false,
  • "safe_prompt": false,
  • "random_seed": 1337
}

Response samples

Content type
application/json
Example
{
  • "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
  • "object": "chat.completion",
  • "created": 1702256327,
  • "model": "mistral-small-latest",
  • "choices": [
    ],
  • "usage": {
    }
}

Create FIM Completions

Authorizations:
ApiKeyAuth
Request Body schema: application/json
required
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 prompt and a suffix the model will fill what is between them. When suffix is not provided, the model will simply execute completion starting with prompt.

model
required
string or null

ID of the model to use. Only compatible for now with:

  • codestral-2405
  • codestral-latest
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 but not both.

top_p
number or null [ 0 .. 1 ]
Default: 1

Nucleus sampling, where the model considers the results of the tokens with with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

We generally recommend altering this or temperature but not both.

max_tokens
integer or null >= 0

The maximum number of tokens to generate in the completion.

The token count of your prompt plus max_tokens cannot exceed the model's context length.

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

Content type
application/json
{
  • "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

Content type
application/json
{
  • "id": "5b35cc2e69bf4ba9a11373ee1f1937f8",
  • "object": "chat.completion",
  • "created": 1702256327,
  • "model": "codestral-latest",
  • "choices": [
    ],
  • "usage": {
    }
}

Create Embeddings

Authorizations:
ApiKeyAuth
Request Body schema: application/json
required
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

Content type
application/json
{
  • "model": "mistral-embed",
  • "input": [
    ],
  • "encoding_format": "float"
}

Response samples

Content type
application/json
{
  • "id": "embd-aad6fc62b17349b192ef09225058bc45",
  • "object": "list",
  • "data": [
    ],
  • "model": "string",
  • "usage": {
    }
}

List Available Models

Authorizations:
ApiKeyAuth

Responses

Response samples

Content type
application/json
{
  • "object": "string",
  • "data": [
    ]
}

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:
ApiKeyAuth
Request Body schema: multipart/form-data
required
purpose
required
any (Purpose)

The intended purpose of the uploaded file. Only accepts fine-tuning (fine-tune) for now.

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:

file=@path/to/your/file.jsonl;filename=custom_name.jsonl

Otherwise, you can just keep the original file name:

file=@path/to/your/file.jsonl

Responses

Response samples

Content type
application/json
{
  • "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:
ApiKeyAuth

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "object": "string"
}

Retrieve File

Returns information about a specific file.

Authorizations:
ApiKeyAuth
path Parameters
file_id
required
string (File Id)

The ID of the file to use for this request.

Responses

Response samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "object": "string",
  • "bytes": 0,
  • "created_at": 0,
  • "filename": "string",
  • "purpose": "fine-tune"
}

Delete File

Delete a file.

Authorizations:
ApiKeyAuth
path Parameters
file_id
required
string (File Id)

The ID of the file to use for this request.

Responses

Response samples

Content type
application/json
{
  • "id": "97f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "object": "file",
  • "deleted": true
}

List Fine Tuning Jobs

Get a list of fine tuning jobs for your organization and user.

Authorizations:
ApiKeyAuth
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

Content type
application/json
{
  • "data": [ ],
  • "object": "list"
}

Create Fine Tuning Job

Create a new fine tuning job, it will be queued for processing.

Authorizations:
ApiKeyAuth
query Parameters
dry_run
bool
Default: false
  • If true the job is not spawned, instead the query returns a handful of useful metadata for the user to perform sanity checks (see JobMetadata response).
  • Otherwise, the job is started and the query returns the job ID along with some of the input parameters (see JobOut response).
Request Body schema: application/json
required
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 checkpoints when getting the status of a running fine-tuning job.

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 ft:open-mistral-7b:my-great-model:xxx...

Array of objects (Integrations) unique

A list of integrations to enable for your fine-tuning job.

Responses

Request samples

Content type
application/json
{
  • "model": "open-mistral-7b",
  • "training_files": [
    ],
  • "validation_files": [
    ],
  • "hyperparameters": {
    },
  • "suffix": "string",
  • "integrations": [
    ]
}

Response samples

Content type
application/json
Example
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "hyperparameters": {
    },
  • "model": "open-mistral-7b",
  • "status": "QUEUED",
  • "job_type": "string",
  • "created_at": 0,
  • "modified_at": 0,
  • "training_files": [
    ],
  • "validation_files": [ ],
  • "object": "job",
  • "fine_tuned_model": "string",
  • "integrations": [
    ]
}

Get Fine Tuning Job

Get a fine tuned job details by its UUID.

Authorizations:
ApiKeyAuth
path Parameters
job_id
required
string <uuid> (Job Id)

The ID of the job to analyse.

Responses

Response samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "hyperparameters": {
    },
  • "model": "open-mistral-7b",
  • "status": "QUEUED",
  • "job_type": "string",
  • "created_at": 0,
  • "modified_at": 0,
  • "training_files": [
    ],
  • "validation_files": [ ],
  • "object": "job",
  • "fine_tuned_model": "string",
  • "integrations": [
    ],
  • "events": [ ],
  • "checkpoints": [ ]
}

Cancel Fine Tuning Job

Request the cancellation of a fine tuning job.

Authorizations:
ApiKeyAuth
path Parameters
job_id
required
string <uuid> (Job Id)

Responses

Response samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "hyperparameters": {
    },
  • "model": "open-mistral-7b",
  • "status": "QUEUED",
  • "job_type": "string",
  • "created_at": 0,
  • "modified_at": 0,
  • "training_files": [
    ],
  • "validation_files": [ ],
  • "object": "job",
  • "fine_tuned_model": "string",
  • "integrations": [
    ],
  • "events": [ ],
  • "checkpoints": [ ]
}