---
title: "Studio Chat Complete"
method: POST
path: "/studio/v1/chat/completions"
tags: ["Jamba Complete"]
---

# Studio Chat Complete

`POST /studio/v1/chat/completions`

This is the endpoint for the [Jamba Instruct model](https://docs.ai21.com/docs/jamba-models).
This is a foundation model that supports both single-turn (question answering,
text completion) and multi-turn (chat style) interactions.

You can optionally stream results if you want to get the response as each
token is generated, rather than waiting for the entire response.

## Request body

- ChatRequest
  - `model` 'jamba-mini' | 'jamba-large' | 'jamba-large-1.7' | 'jamba-large-1.7-2025-07' | 'jamba-mini-2' | 'jamba-mini-2-2026-01', required — An enumeration.
  - `messages` union[], required — The previous messages in this chat, from oldest (index 0) to newest. Messages must be alternating `user`/`assistant` messages, optionally starting with a `system` message. For single turn interactions, this should be an optional `system` message, and a single `user` message. Maximum total size for the list is about 256K tokens.
    - union
      - UserMessage
        - `role` 'user' — The role of an individual message. - `user`: Input provided by the user. Any instructions given here that conflict with instructions given in the `system` prompt take precedence over the `system` prompt instructions. - `assistant`: Response generated by the model. - `system`: Initial instructions provided to the system to provide general guidance on the tone and voice of the generated message. An initial system message is optional but recommended to provide guidance on the tone of the chat. For example, "You are a helpful chatbot with a background in earth sciences and a charming French accent."
        - `content` string, required
      - AssistantMessage
        - `role` 'assistant' — The role of an individual message. - `user`: Input provided by the user. Any instructions given here that conflict with instructions given in the `system` prompt take precedence over the `system` prompt instructions. - `assistant`: Response generated by the model. - `system`: Initial instructions provided to the system to provide general guidance on the tone and voice of the generated message. An initial system message is optional but recommended to provide guidance on the tone of the chat. For example, "You are a helpful chatbot with a background in earth sciences and a charming French accent."
        - `content` string
        - `tool_calls` ToolCall[]
          - `id` string, required — A unique ID for the request (not the message). Repeated identical requests get different IDs. However, for a streaming response, the ID will be the same for all responses in the stream.
          - `type` 'function'
          - `function` ToolFunction, required
            - `name` string, required
            - `arguments` string, required
        - `reasoning_content` string
      - ToolMessage
        - `role` 'tool' — The role of an individual message. - `user`: Input provided by the user. Any instructions given here that conflict with instructions given in the `system` prompt take precedence over the `system` prompt instructions. - `assistant`: Response generated by the model. - `system`: Initial instructions provided to the system to provide general guidance on the tone and voice of the generated message. An initial system message is optional but recommended to provide guidance on the tone of the chat. For example, "You are a helpful chatbot with a background in earth sciences and a charming French accent."
        - `content` string, required
        - `tool_call_id` string, required
      - SystemMessage
        - `role` 'system' — The role of an individual message. - `user`: Input provided by the user. Any instructions given here that conflict with instructions given in the `system` prompt take precedence over the `system` prompt instructions. - `assistant`: Response generated by the model. - `system`: Initial instructions provided to the system to provide general guidance on the tone and voice of the generated message. An initial system message is optional but recommended to provide guidance on the tone of the chat. For example, "You are a helpful chatbot with a background in earth sciences and a charming French accent."
        - `content` string, required
  - `tools` LanguageStudioApiServerDataTypesChatToolDefinition[]
    - `type` 'function', required
    - `function` FunctionToolDefinition, required
      - `name` string, required
      - `description` string
      - `parameters` ToolParameters
        - `type` 'object' — Type of the parameter schema, only `object` is supported
        - `properties` object, required
        - `required` string[] — List of required properties
  - `n` integer — How many chat responses to generate. _Range: 1 – 16_ **Notes:** - If `n > 1`, setting `temperature=0` will fail because all answers are guaranteed to be duplicates. - `n` must be 1 when `stream = True`
  - `max_tokens` integer — The maximum number of tokens to allow for each generated response message. Typically the best way to limit output length is by providing a length limit in the system prompt (for example, "limit your answers to three sentences"). _Range: 0 – 4096_
  - `temperature` number — How much variation to provide in each answer. Setting this value to 0 guarantees the same response to the same question every time. Setting a higher value encourages more variation. Modifies the distribution from which tokens are sampled. [More information](https://docs.ai21.com/docs/sampling-from-language-models#temperature) _Range: 0.0 – 2.0_
  - `top_p` number — Limit the pool of next tokens in each step to the top N percentile of possible tokens, where 1.0 means the pool of all possible tokens, and 0.01 means the pool of only the most likely next tokens. [More information] (https://docs.ai21.com/docs/sampling-from-language-models#topp) _Range: 0 \<= value \<=1.0_
  - `stop` union — End the message when the model generates one of these strings. The stop sequence is not included in the generated message. Each sequence can be up to 64K long, and can contain newlines as `\n` characters. Examples: - Single stop string with a word and a period: "monkeys." - Multiple stop strings and a newline: ["cat", "dog", " .", "####", "\n"]
    - string
    - string[]
  - `stream` boolean — Whether or not to stream the result one token at a time using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events). This can be useful when waiting for long results where a long wait time for an answer can be problematic, such as a chatbot. If set to `True`, then `n` must be 1. A streaming response is different than the non-streaming response.
  - `mock_response` MockResponseConfig
    - `response_delay_seconds` number
    - `stream_response_delay_between_deltas_seconds` number
  - `documents` DocumentSchema[]
    - `id` string — A unique ID for the request (not the message). Repeated identical requests get different IDs. However, for a streaming response, the ID will be the same for all responses in the stream.
    - `content` string, required
    - `metadata` object
  - `response_format` ResponseFormat
    - `type` 'text' | 'json_object', required

## Response `200`

Successful Response

- union
  - ChatCompletion — Used for non-streaming responses. Streaming responses return `ChatCompletionVllmStreamingMessage`.
    - `id` string, required — A unique ID for the request (not the message). Repeated identical requests get different IDs. However, for a streaming response, the ID will be the same for all responses in the stream.
    - `choices` ChatCompletionResponseChoice[], required — One or more responses, depending on the `n` parameter from the request.
      - `index` integer, required — Zero-based index of the message in the list of messages. Note that this might not correspond with the position in the response list.
      - `message` AssistantMessage, required
        - `role` 'assistant' — The role of an individual message. - `user`: Input provided by the user. Any instructions given here that conflict with instructions given in the `system` prompt take precedence over the `system` prompt instructions. - `assistant`: Response generated by the model. - `system`: Initial instructions provided to the system to provide general guidance on the tone and voice of the generated message. An initial system message is optional but recommended to provide guidance on the tone of the chat. For example, "You are a helpful chatbot with a background in earth sciences and a charming French accent."
        - `content` string
        - `tool_calls` ToolCall[]
          - `id` string, required — A unique ID for the request (not the message). Repeated identical requests get different IDs. However, for a streaming response, the ID will be the same for all responses in the stream.
          - `type` 'function'
          - `function` ToolFunction, required
            - `name` string, required
            - `arguments` string, required
        - `reasoning_content` string
      - `logprobs` Logprobs
        - `content` LogprobsData[], required
          - `token` string, required
          - `logprob` number, required
          - `top_logprobs` TopLogprobsData[]
            - `token` string, required
            - `logprob` number, required
      - `finish_reason` string — Why the message ended. Possible reasons: - `stop`: The response ended naturally as a complete answer (due to [end-of-sequence token](https://huggingface.co/docs/transformers/v4.32.1/en/llm_tutorial#generate-text)) or because the model generated a stop sequence provided in the request. - `length`: The response ended by reaching `max_tokens`.
    - `usage` UsageInfo, required
      - `prompt_tokens` integer, required — Number of tokens in the prompt for this request. Note that the prompt token includes the entire message history, plus extra tokens needed by the system when combining the list of prompt messages into a single message, as required by the model. The number of extra tokens is typically proportional to the number of messages in the thread, and should be relatively small.
      - `completion_tokens` integer, required — Number of tokens in the response message.
      - `total_tokens` integer, required — `prompt_tokens` + `completion_tokens`.
    - `meta` object
  - ChatCompletionVllmStreamingMessage[]
    - `id` string, required — A unique ID for the request (not the message). Repeated identical requests get different IDs. However, for a streaming response, the ID will be the same for all responses in the stream.
    - `choices` ChatCompletionResponseDeltaChoice[], required — The message
      - `index` integer, required — Always zero in streamed responses.
      - `delta` union, required — - **The first message** in the stream will be an object set to `{"role":"assistant"}`. - **Subsequent messages** will have an object `{"content": __token__}` with the generated token.
        - ChatStreamingFirstDelta
          - `role` 'system' | 'user' | 'assistant' | 'tool', required — The role of an individual message. - `user`: Input provided by the user. Any instructions given here that conflict with instructions given in the `system` prompt take precedence over the `system` prompt instructions. - `assistant`: Response generated by the model. - `system`: Initial instructions provided to the system to provide general guidance on the tone and voice of the generated message. An initial system message is optional but recommended to provide guidance on the tone of the chat. For example, "You are a helpful chatbot with a background in earth sciences and a charming French accent."
        - ChatStreamingContentDelta
          - `content` string, required
        - ChatStreamingToolCallsFirstDelta
          - `tool_calls` ToolCallDeltaStart[], required
            - `id` string, required — A unique ID for the request (not the message). Repeated identical requests get different IDs. However, for a streaming response, the ID will be the same for all responses in the stream.
            - `index` integer, required
            - `type` 'function', required
            - `function` ToolFunctionDeltaStart, required
              - …
        - ChatStreamingToolCallsDelta
          - `tool_calls` ToolCallDelta[], required
            - `index` integer, required
            - `function` ToolFunctionDelta, required
              - …
      - `logprobs` Logprobs
        - `content` LogprobsData[], required
          - `token` string, required
          - `logprob` number, required
          - `top_logprobs` TopLogprobsData[]
            - `token` string, required
            - `logprob` number, required
      - `finish_reason` string — One of the following string values: - `null`: All messages but the last will return null for `finish_reason`. - `stop`: The response ended naturally as a complete answer (due to [end-of-sequence token](https://huggingface.co/docs/transformers/v4.32.1/en/llm_tutorial#generate-text)) or because the model generated a stop sequence provided in the request. - `length`: The response ended by reaching `max_tokens`.
    - `usage` UsageInfo
      - `prompt_tokens` integer, required — Number of tokens in the prompt for this request. Note that the prompt token includes the entire message history, plus extra tokens needed by the system when combining the list of prompt messages into a single message, as required by the model. The number of extra tokens is typically proportional to the number of messages in the thread, and should be relatively small.
      - `completion_tokens` integer, required — Number of tokens in the response message.
      - `total_tokens` integer, required — `prompt_tokens` + `completion_tokens`.
    - `meta` object

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/ai21/apis/ai21-studio-api.md) · [All operations](https://skmtc.net/ai21/apis/ai21-studio-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ai21/ai21-studio-api/versions/4105747cd57d/schema)
