---
title: "Agents Completion"
method: POST
path: "/v1/agents/completions"
tags: ["agents"]
---

# Agents Completion

`POST /v1/agents/completions`

Agents Completion

## Request body

- AgentsCompletionRequest
  - `max_tokens` integer, nullable — 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 — 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` union — Stop generation if this token is detected. Or if one of these tokens is detected when providing an array
    - string
    - string[]
  - `random_seed` integer, nullable — The seed to use for random sampling. If set, different calls will generate deterministic results.
  - `metadata` object, nullable
  - `messages` union[], required — The prompt(s) to generate completions for, encoded as a list of dict with role and content.
    - union
      - SystemMessage
        - `role` 'system'
        - `content` union, required
          - string
          - SystemMessageContentChunks[]
            - union
              - …
      - UserMessage
        - `role` 'user'
        - `content` union, required
          - string
          - ContentChunk[]
            - union
              - …
      - AssistantMessage
        - `role` 'assistant'
        - `content` union
          - string
          - ContentChunk[]
            - union
              - …
        - `tool_calls` ToolCall[], nullable
          - `id` string
          - `type` 'function'
          - `function` FunctionCall, required
            - `name` string, required
            - `arguments` union, required
              - …
          - `index` integer
        - `prefix` boolean — Set this to `true` when adding an assistant message as prefix to condition the model response. The role of the prefix message is to force the model to start its answer by the content of the message.
      - ToolMessage
        - `role` 'tool'
        - `content` union, required
          - string
          - ContentChunk[]
            - union
              - …
        - `tool_call_id` string, nullable
        - `name` string, nullable
  - `response_format` ResponseFormat — Specify the format that the model must output. By default it will use `{ "type": "text" }`. Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is in JSON. When using JSON mode you MUST also instruct the model to produce JSON yourself with a system or a user message. Setting to `{ "type": "json_schema" }` enables JSON schema mode, which guarantees the message the model generates is in JSON and follows the schema you provide.
    - `type` 'text' | 'json_object' | 'json_schema'
    - `json_schema` JsonSchema
      - `name` string, required
      - `description` string, nullable
      - `schema` object, required
      - `strict` boolean
  - `tools` union[], nullable
    - union
      - Tool
        - `type` 'function'
        - `function` Function, required
          - `name` string, required
          - `description` string
          - `strict` boolean
          - `parameters` object, required
      - WebSearchTool
        - `tool_configuration` ToolConfiguration
          - `exclude` string[], nullable
          - `include` string[], nullable
          - `requires_confirmation` string[], nullable
        - `type` 'web_search'
      - WebSearchPremiumTool
        - `tool_configuration` ToolConfiguration
          - `exclude` string[], nullable
          - `include` string[], nullable
          - `requires_confirmation` string[], nullable
        - `type` 'web_search_premium'
      - CodeInterpreterTool
        - `tool_configuration` ToolConfiguration
          - `exclude` string[], nullable
          - `include` string[], nullable
          - `requires_confirmation` string[], nullable
        - `type` 'code_interpreter'
      - ImageGenerationTool
        - `tool_configuration` ToolConfiguration
          - `exclude` string[], nullable
          - `include` string[], nullable
          - `requires_confirmation` string[], nullable
        - `type` 'image_generation'
      - DocumentLibraryTool
        - `tool_configuration` ToolConfiguration
          - `exclude` string[], nullable
          - `include` string[], nullable
          - `requires_confirmation` string[], nullable
        - `type` 'document_library'
        - `library_ids` string[], required — Ids of the library in which to search.
      - CustomConnector
        - `type` 'connector'
        - `connector_id` string, required
        - `authorization` union
          - OAuth2TokenAuth
            - `type` 'oauth2-token'
            - `value` string, required
          - APIKeyAuth
            - `type` 'api-key'
            - `value` string, required
        - `tool_configuration` ToolConfiguration
          - `exclude` string[], nullable
          - `include` string[], nullable
          - `requires_confirmation` string[], nullable
  - `tool_choice` union
    - ToolChoice — ToolChoice is either a ToolChoiceEnum or a ToolChoice
      - `type` 'function'
      - `function` FunctionName, required — this restriction of `Function` is used to select a specific function to call
        - `name` string, required
    - 'auto' | 'none' | 'any' | 'required'
  - `presence_penalty` number, nullable — The `presence_penalty` determines how much the model penalizes the repetition of words or phrases. A higher presence penalty encourages the model to use a wider variety of words and phrases, making the output more diverse and creative.
  - `frequency_penalty` number, nullable — The `frequency_penalty` penalizes the repetition of words based on their frequency in the generated text. A higher frequency penalty discourages the model from repeating words that have already appeared frequently in the output, promoting diversity and reducing repetition.
  - `n` integer, nullable — Number of completions to return for each request, input tokens are only billed once.
  - `prediction` Prediction — Enable users to specify an expected completion, optimizing response times by leveraging known or predictable content.
    - `type` 'content'
    - `content` string
  - `parallel_tool_calls` boolean
  - `reasoning_effort` 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'
  - `prompt_mode` 'reasoning' — Available options to the prompt_mode argument on the chat completion endpoint. Values represent high-level intent. Assignment to actual SPs is handled internally. System prompt may include knowledge cutoff date, model capabilities, tone to use, safety guidelines, etc.
  - `guardrails` GuardrailConfig[], nullable
    - `block_on_error` boolean — If true, return HTTP 403 and block request in the event of a server-side error
    - `moderation_llm_v1` ModerationLLMV1Config
      - `model_name` string — Override model name. Should be omitted in general.
      - `custom_category_thresholds` ModerationLLMV1CategoryThresholds
        - `sexual` number, nullable
        - `hate_and_discrimination` number, nullable
        - `violence_and_threats` number, nullable
        - `dangerous_and_criminal_content` number, nullable
        - `selfharm` number, nullable
        - `health` number, nullable
        - `financial` number, nullable
        - `law` number, nullable
        - `pii` number, nullable
      - `ignore_other_categories` boolean — If true, only evaluate categories in custom_category_thresholds; others are ignored.
      - `action` 'none' | 'block'
    - `moderation_llm_v2` ModerationLLMV2Config
      - `model_name` string — Override model name. Should be omitted in general.
      - `custom_category_thresholds` ModerationLLMV2CategoryThresholds
        - `sexual` number, nullable
        - `hate_and_discrimination` number, nullable
        - `violence_and_threats` number, nullable
        - `dangerous` number, nullable
        - `criminal` number, nullable
        - `selfharm` number, nullable
        - `health` number, nullable
        - `financial` number, nullable
        - `law` number, nullable
        - `pii` number, nullable
        - `jailbreaking` number, nullable
      - `ignore_other_categories` boolean — If true, only evaluate categories in custom_category_thresholds; others are ignored.
      - `action` 'none' | 'block'
  - `prompt_cache_key` string, nullable
  - `agent_id` string, required — The ID of the agent to use for this completion.

## Response `200`

Successful Response

- ChatCompletionResponse
  - `id` string, required
  - `object` string, required
  - `model` string, required
  - `usage` UsageInfo, required
    - `prompt_tokens` integer, required
    - `completion_tokens` integer, required
    - `total_tokens` integer, required
    - `prompt_audio_seconds` integer, nullable
  - `created` integer, required
  - `choices` ChatCompletionChoice[], required
    - `index` integer, required
    - `message` AssistantMessage
      - `role` 'assistant'
      - `content` union
        - string
        - ContentChunk[]
          - union
            - TextChunk
              - …
            - ImageURLChunk — {"type":"image_url","image_url":"data:image/png;base64,iVBORw0"}
              - …
            - DocumentURLChunk
              - …
            - ReferenceChunk
              - …
            - FileChunk
              - …
            - ThinkChunk
              - …
            - AudioChunk
              - …
      - `tool_calls` ToolCall[], nullable
        - `id` string
        - `type` 'function'
        - `function` FunctionCall, required
          - `name` string, required
          - `arguments` union, required
            - object
            - string
        - `index` integer
      - `prefix` boolean — Set this to `true` when adding an assistant message as prefix to condition the model response. The role of the prefix message is to force the model to start its answer by the content of the message.
    - `messages` DeltaMessage[]
      - `role` string, nullable
      - `content` union
        - string
        - ContentChunk[]
          - union
            - TextChunk
              - …
            - ImageURLChunk — {"type":"image_url","image_url":"data:image/png;base64,iVBORw0"}
              - …
            - DocumentURLChunk
              - …
            - ReferenceChunk
              - …
            - FileChunk
              - …
            - ThinkChunk
              - …
            - AudioChunk
              - …
      - `tool_calls` ToolCall[], nullable
        - `id` string
        - `type` 'function'
        - `function` FunctionCall, required
          - `name` string, required
          - `arguments` union, required
            - object
            - string
        - `index` integer
      - `tool_call_id` string, nullable
      - `index` integer, nullable — If the completion returns multiple messages, this is to specify which message this delta is for.
      - `metadata` object, nullable
    - `finish_reason` 'stop' | 'length' | 'model_length' | 'error' | 'tool_calls', required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/mistral/apis/mistral-ai-api.md) · [All operations](https://skmtc.net/mistral/apis/mistral-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mistral/mistral-ai-api/versions/933c4ebdcd72/schema)
