Mistral AI
    Mistral AI
    • Create Chat Completions
      POST
    • Create FIM Completions
      POST
    • Create Embeddings
      POST
    • List Available Models
      GET
    • Delete Model
      DELETE
    • Upload File
      POST
    • List Files
      GET
    • Retrieve File
      GET
    • Delete File
      DELETE
    • List Fine Tuning Jobs
      GET
    • Create Fine Tuning Job
      POST
    • Get Fine Tuning Job
      GET
    • Cancel Fine Tuning Job
      POST

      Create Chat Completions

      Develop Env
      https://dev.your-api-server.com
      Develop Env
      https://dev.your-api-server.com
      POST
      /chat/completions
      Request Request Example
      Shell
      JavaScript
      Java
      Swift
      curl --location --request POST 'https://dev.your-api-server.com/chat/completions' \
      --header 'Content-Type: application/json' \
      --data-raw '{
          "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": null,
          "stream": false,
          "safe_prompt": false,
          "random_seed": null
      }'
      Response Response Example
      {
          "id": "cmpl-e5cc70bb28c444948073e77776eb30ef",
          "object": "chat.completion",
          "created": 1702256327,
          "model": "mistral-small-latest",
          "choices": [
              {
                  "index": 0,
                  "message": {
                      "role": "user",
                      "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
          }
      }

      Request

      Body Params application/json
      optional
      Any of
      model
      string 
      required
      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.
      Example:
      mistral-small-latest
      messages
      array [object {3}] 
      required
      The prompt(s) to generate completions for, encoded as a list of dict with role and content.
      temperature
      number  | null 
      optional
      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.
      >= 0<= 1
      Default:
      0.7
      top_p
      number  | null 
      optional
      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.
      >= 0<= 1
      Default:
      1
      max_tokens
      integer  | null 
      optional
      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.
      >= 0
      Default:
      null
      Example:
      512
      stream
      boolean  | null 
      optional
      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.
      Default:
      false
      safe_prompt
      boolean 
      optional
      Whether to inject a safety prompt before all conversations.
      Default:
      false
      random_seed
      integer 
      optional
      The seed to use for random sampling. If set, different calls will generate deterministic results.
      Default:
      null
      Example:
      1337
      Examples

      Responses

      🟢200OK
      application/json
      Body
      optional
      One of
      id
      string 
      optional
      Example:
      cmpl-e5cc70bb28c444948073e77776eb30ef
      object
      string 
      optional
      Example:
      chat.completion
      created
      integer 
      optional
      Example:
      1702256327
      model
      string 
      optional
      Example:
      mistral-small-latest
      choices
      array [object {3}] 
      optional
      usage
      object 
      optional
      Modified at 2024-12-10 10:11:20
      Next
      Create FIM Completions
      Built with