---
title: "Chat"
method: POST
path: "/v1/chat/completions"
---

# Chat

`POST /v1/chat/completions`

## Headers

- `X-Amz-Cf-Id` string, nullable
- `CF-RAY` string, nullable
- `X-delay-time` number, nullable

## Request body

- ChatCompletionRequest — Generic base class for chat completion requests.
  - `clear_thinking` boolean, nullable — When True, removes reasoning content from messages that appear before the latest user message.
  - `disable_reasoning` boolean, nullable — Disables reasoning for reasoning models. If set to True, the model will not use any reasoning in its response.
  - `frequency_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
  - `logit_bias` object, nullable — Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
  - `logprobs` boolean, nullable — Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned in the content of message.
  - `max_completion_tokens` integer, nullable — An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
  - `max_tokens` integer, nullable — The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. This value is now deprecated in favor of max_completion_tokens.
  - `messages` union[], required
    - union
      - SystemMessageRequest — A message request from the system.
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `name` string, nullable
        - `role` 'system'
      - DeveloperMessageRequest — A message request from the developer: Currently only for openai models, where they are functionally the same as system
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `name` string, nullable
        - `role` 'developer'
      - UserMessageRequest — A message request from the user.
        - `content` union, required
          - string
          - union[]
            - union
              - …
        - `name` string, nullable
        - `role` 'user'
      - AssistantMessageRequest — A message request from an assistant.
        - `content` union
          - string
          - TextContent[]
            - `text` string, required
            - `type` 'text', required
        - `name` string, nullable
        - `reasoning` union
          - string
          - TextContent[]
            - `text` string, required
            - `type` 'text', required
        - `role` 'assistant'
        - `tool_calls` AssistantToolCall[], nullable
          - `function` AssistantToolCallFunction, required — A function call for an assistant tool.
            - `arguments` string, required
            - `name` string, required
          - `id` string, required
          - `index` integer, nullable
          - `type` 'function', required
      - ToolMessageRequest — A message request from a tool.
        - `content` union, required
          - string
          - TextContent[]
            - `text` string, required
            - `type` 'text', required
        - `name` string, nullable
        - `role` 'tool'
        - `tool_call_id` string, required
  - `min_completion_tokens` integer, nullable — The minimum number of tokens to generate for a completion. If not specified or set to 0, the model will generate as many tokens as it deems necessary. Setting to -1 sets to max sequence length.
  - `min_tokens` integer, nullable — The minimum number of tokens to generate for a completion. If not specified or set to 0, the model will generate as many tokens as it deems necessary. Setting to -1 sets to max sequence length.
  - `model` string, required
  - `model_parameters` object, nullable — Model-specific parameters. The accepted keys and values are defined per-model by the model's ``model_parameters`` schema. The schema is used downstream to validate the contents of this field. Unsupported for models that declare none.
  - `n` integer, nullable — How many chat completion choices to generate for each input message. Note that you will be charged based on the number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
  - `parallel_tool_calls` boolean, nullable
  - `prediction` Prediction
    - `content` union, required
      - string
      - TextContent[]
        - `text` string, required
        - `type` 'text', required
    - `type` 'content', required
  - `presence_penalty` number, nullable — Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
  - `prompt_cache_key` string, nullable — An optional opaque string. The requests with the same prompt cache key would highly likely share the same prompt prefixes. Examples would be IDs of chat conversations, IDs of users, the hashes of system prompts, etc.
  - `reasoning_effort` 'none' | 'low' | 'medium' | 'high'
  - `reasoning_format` 'none' | 'parsed' | 'text_parsed' | 'raw' | 'hidden'
  - `response_format` union
    - ResponseFormatText — A response format for text.
      - `type` 'text', required
    - ResponseFormatJSONObject — A response format for a JSON object.
      - `type` 'json_object', required
    - ResponseFormatJSONSchema — A response format for a JSON schema.
      - `json_schema` JSONSchema, required — A JSON Schema object.
        - `description` string, nullable
        - `name` string, required
        - `schema` object, nullable
        - `strict` boolean, nullable
      - `type` 'json_schema', required
  - `seed` integer, nullable — If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same `seed` and parameters should return the same result. Determinism is not guaranteed.
  - `service_tier` 'auto' | 'default' | 'flex' | 'priority'
  - `stop` union — Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
    - string
    - string[]
  - `stream` boolean, nullable
  - `stream_options` StreamOptions — Options for streaming.
    - `include_usage` boolean, nullable
  - `temperature` number, nullable — What sampling temperature to use, between 0 and 2. 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.
  - `tool_choice` union
    - 'none' | 'auto' | 'required' — A tool choice object.
    - ChoiceObject — A choice object.
      - `function` ChoiceObjectFunction, required — A function for a choice object.
        - `name` string, required
      - `type` string, required
  - `tools` Tool[], nullable
    - `function` FunctionObject, required — A function object.
      - `description` string, nullable
      - `name` string, required
      - `parameters` Parameters — Represents the parameters a function accepts. This model is designed to be flexible to accommodate any JSON Schema. The key-value pairs you provide will define the parameters.
      - `strict` boolean
    - `type` string, required
  - `top_logprobs` integer, nullable — An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability. logprobs must be set to true if this parameter is used.
  - `top_p` number, nullable — An alternative to sampling with temperature, called 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.
  - `user` string, nullable — A unique identifier representing your end-user, which can help Cerebras to monitor and detect abuse.

## Response `200`

Successful Response

- union
  - ChatCompletionResponse
    - `choices` ChatCompletionChoice[], required
      - `finish_reason` 'stop' | 'length' | 'content_filter' | 'tool_calls', nullable
      - `index` integer, required
      - `logprobs` ChatCompletionLogProbs
        - `content` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
        - `refusal` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
      - `message` ChatCompletionResponseMessage, required
        - `content` string, nullable
        - `reasoning` string, nullable
        - `role` 'assistant' | 'user' | 'system' | 'tool', required
        - `tool_calls` ChunkAssistantToolCall[], nullable
          - `function` ChunkAssistantToolCallFunction, required — Streaming only. Represents a function in an assistant tool call.
            - `arguments` string, nullable
            - `name` string, nullable
          - `id` string, nullable
          - `index` integer, nullable
          - `type` 'function', required
      - `reasoning_logprobs` ChatCompletionLogProbs
        - `content` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
        - `refusal` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
    - `created` integer, required
    - `id` string, required
    - `model` string, required
    - `object` 'chat.completion', required
    - `service_tier` string, nullable
    - `system_fingerprint` string, required
    - `time_info` TimeInfo — Time information for different phases of request processing. All times are measured in seconds.
      - `completion_time` number, nullable
      - `created` number, nullable
      - `prompt_time` number, nullable
      - `queue_time` number, nullable
      - `total_time` number, nullable
    - `usage` Usage
      - `completion_tokens` integer
      - `completion_tokens_details` CompletionTokensDetails
        - `accepted_prediction_tokens` integer, nullable
        - `reasoning_tokens` integer, nullable
        - `rejected_prediction_tokens` integer, nullable
      - `image_tokens` integer, nullable
      - `prompt_tokens` integer
      - `prompt_tokens_details` PromptTokensDetails
        - `cached_tokens` integer
      - `total_tokens` integer
  - ChatChunkResponse
    - `choices` ChatChunkChoice[], nullable
      - `delta` ChunkResponseMessage
        - `content` string, nullable
        - `reasoning` string, nullable
        - `role` 'assistant' | 'user' | 'system' | 'tool', nullable
        - `tokens` integer[], nullable
        - `tool_calls` ChunkAssistantToolCall[], nullable
          - `function` ChunkAssistantToolCallFunction, required — Streaming only. Represents a function in an assistant tool call.
            - `arguments` string, nullable
            - `name` string, nullable
          - `id` string, nullable
          - `index` integer, nullable
          - `type` 'function', required
      - `finish_reason` 'stop' | 'length' | 'content_filter' | 'tool_calls', nullable
      - `index` integer, required
      - `logprobs` ChatCompletionLogProbs
        - `content` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
        - `refusal` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
      - `reasoning_logprobs` ChatCompletionLogProbs
        - `content` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
        - `refusal` LogProbsContent[], nullable
          - `bytes` integer[], nullable
          - `logprob` number, required
          - `token` string, required
          - `top_logprobs` TopLogProbs[], required
            - `bytes` integer[], nullable
            - `logprob` number, required
            - `token` string, required
      - `text` string, nullable
      - `tokens` integer[], nullable
    - `created` integer, required
    - `id` string, required
    - `model` string, required
    - `object` 'chat.completion.chunk', required
    - `service_tier` string, nullable
    - `system_fingerprint` string, required
    - `time_info` TimeInfo — Time information for different phases of request processing. All times are measured in seconds.
      - `completion_time` number, nullable
      - `created` number, nullable
      - `prompt_time` number, nullable
      - `queue_time` number, nullable
      - `total_time` number, nullable
    - `usage` Usage
      - `completion_tokens` integer
      - `completion_tokens_details` CompletionTokensDetails
        - `accepted_prediction_tokens` integer, nullable
        - `reasoning_tokens` integer, nullable
        - `rejected_prediction_tokens` integer, nullable
      - `image_tokens` integer, nullable
      - `prompt_tokens` integer
      - `prompt_tokens_details` PromptTokensDetails
        - `cached_tokens` integer
      - `total_tokens` integer
  - ErrorChunkResponse
    - `error` ErrorChunkContent, required
      - `code` string, nullable
      - `id` string, nullable
      - `message` string, nullable
      - `param` string, nullable
      - `type` string, nullable
    - `status_code` integer, required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/cerebras/apis/cerebras-cloud-api.md) · [All operations](https://skmtc.net/cerebras/apis/cerebras-cloud-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/cerebras/cerebras-cloud-api/revisions/130749c46caf/schema)
