> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiekou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Chat Conversation Request

Generate a model response based on the specified chat conversation

## Request Headers

<ParamField header="Content-Type" type="string" required={true}>
  Enum value: `application/json`
</ParamField>

<ParamField header="Authorization" type="string" required={true}>
  Bearer authentication format: Bearer \{\{API Key}}.
</ParamField>

## Request Body

<ParamField body="model" type="string" required={true}>
  The name of the model to use.
</ParamField>

<ParamField body="messages" type="object[]" required={true}>
  A list of messages that make up the current conversation.

  <Expandable title="Properties" defaultOpen={false}>
    <ParamField body="content" type="string | object[] | null" required={true}>
      The content of the message. content is required for all messages. For assistant messages containing function calls, content can be null.

      You can use the following parameters for different modalities.

      <Frame>
        <div class="param_frame">
          <Tabs>
            <Tab title="Text Content">
              <p class="param_text">Option 1:</p>
              <p class="param_text">You can use a string type to represent the text content of the message.</p>

              <br />

              <p class="param_text">Option 2:</p>
              <p class="param_text">Use an array of content parts, object\[]. The detailed fields are as follows:</p>

              <ParamField body="type" type="string" required={true}>
                The type of the content part, which is `text` in this case.
              </ParamField>

              <ParamField body="text" type="string" required={true}>
                The text content.
              </ParamField>
            </Tab>

            <Tab title="Image Content">
              <p class="param_text">Only vision-language models can be used.</p>
              <p class="param_text">An array of content parts, object\[]. The detailed fields are as follows:</p>

              <ParamField body="type" type="string" required={true}>
                The type of the content part, which is `image_url` in this case.
              </ParamField>

              <ParamField body="image_url" type="string" required={true}>
                <Expandable title="Properties" defaultOpen={true}>
                  <ParamField body="url" type="string" required={true}>
                    The URL of the image or base64-encoded image data (claude series models only support base64-encoded image data).
                  </ParamField>
                </Expandable>
              </ParamField>
            </Tab>

            <Tab title="Video Content">
              <p class="param_text">Only models that support video can be used.</p>
              <p class="param_text">An array of content parts, object\[]. The detailed fields are as follows:</p>

              <ParamField body="type" type="string" required={true}>
                The type of the content part, which is `video_url` in this case.
              </ParamField>

              <ParamField body="video_url" type="string" required={true}>
                <Expandable title="Properties" defaultOpen={true}>
                  <ParamField body="url" type="string" required={true}>
                    The URL of the video.
                  </ParamField>
                </Expandable>
              </ParamField>
            </Tab>
          </Tabs>
        </div>
      </Frame>
    </ParamField>

    <ParamField body="role" type="string" required={true}>
      The role of the message author. Can be system, user, or assistant.

      Enum values: `system`, `user`, `assistant`
    </ParamField>

    <ParamField body="name" type="string">
      The name of the author of this message. Can contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="max_tokens" type="integer" required={true}>
  The maximum number of tokens to generate in the completion.

  If your prompt (previous messages) plus max\_tokens exceeds the model's context length, the behavior depends on context\_length\_exceeded\_behavior. By default, max\_tokens will be reduced to fit within the context window instead of returning an error.
</ParamField>

<ParamField body="stream" type="boolean | null" default={false}>
  Whether to return partial progress as a stream. If set, tokens will be sent as data-only server-sent events (SSE) as they become available, and the stream will terminate with a `data: [DONE]` message.
</ParamField>

<ParamField body="stream_options" type="object | null">
  Options for the streaming response. Set this only when stream is set to true.

  <Expandable title="Properties" defaultOpen={false}>
    <ParamField body="include_usage" type="boolean">
      If set, an additional chunk will be streamed before the data: \[DONE] message. The usage field in this chunk shows token usage statistics for the entire request, while the choices field is always an empty array. All other chunks will also contain a usage field, but its value will be null.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="n" type="integer | null" default={1}>
  The number of completions to generate for each prompt.

  Note: Because this parameter generates many completions, it may quickly consume your token quota. Use it with caution, and make sure you have reasonable settings for max\_tokens and stop.

  Required range: `1 < x < 128`
</ParamField>

<ParamField body="seed" type="integer | null">
  If specified, our system will make a best effort to sample deterministically, so repeated requests with the same seed and parameters should return the same result.
</ParamField>

<ParamField body="frequency_penalty" type="number | null" default={0}>
  Positive values penalize new tokens based on their existing frequency in the text, reducing the likelihood that the model will repeat the same line verbatim.

  If the goal is only to slightly reduce repetitive samples, reasonable values are between 0.1 and 1. If the goal is to strongly suppress repetition, the coefficient can be increased to 2, but this may significantly degrade sample quality. Negative values can be used to increase the likelihood of repetition.

  See also presence\_penalty, which penalizes tokens that have appeared at least once at a fixed rate.

  Required range: `-2 < x < 2`
</ParamField>

<ParamField body="presence_penalty" type="number | null" default={0}>
  Positive values penalize new tokens based on whether they appear in the text, increasing the likelihood that the model will talk about new topics.

  If the goal is only to slightly reduce repetitive samples, reasonable values are between 0.1 and 1. If the goal is to strongly suppress repetition, the coefficient can be increased to 2, but this may significantly degrade sample quality. Negative values can be used to increase the likelihood of repetition.

  See also `frequency_penalty`, which penalizes tokens at an increasing rate based on how frequently they appear.

  Required range: `-2 < x < 2`
</ParamField>

<ParamField body="repetition_penalty" type="number | null">
  Applies a penalty to repeated tokens to discourage or encourage repetition. A value of 1.0 means no penalty, allowing free repetition. Values above 1.0 penalize repetition, reducing the likelihood of repeated tokens. Values between 0.0 and 1.0 reward repetition, increasing the chance of repeated tokens. For a good balance, a value of 1.2 is usually recommended. Note that the penalty applies to both the generated output and the prompt in decoder-only models.

  Required range: `0 < x < 2`
</ParamField>

<ParamField body="stop" type="string | null">
  Up to 4 sequences where the API will stop generating further tokens. The returned text will contain the stop sequence.
</ParamField>

<ParamField body="temperature" type="number | null" default={1}>
  The sampling temperature to use, between 0 and 2. Higher values such as 0.8 make the output more random, while lower values such as 0.2 make it more focused and deterministic.

  We generally recommend changing this or `top_p`, but not both.

  Required range: `0 < x < 2`
</ParamField>

<ParamField body="top_p" type="number | null">
  An alternative to sampling with temperature, called nucleus sampling, where the model considers token results with top\_p probability mass. Thus, 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend changing this or temperature, but not both.

  Required range: `0 < x <= 1`
</ParamField>

<ParamField body="top_k" type="integer | null">
  Top-k sampling is another sampling method where the k most likely next tokens are filtered, and the probability mass is redistributed only among these k next tokens. The value of k controls the number of candidate next tokens at each step during text generation.

  Required range: `1 < x < 128`
</ParamField>

<ParamField body="min_p" type="number | null">
  Represents the minimum probability for tokens to be considered, relative to the probability of the most likely token.

  Required range: `0 <= x <= 1`
</ParamField>

<ParamField body="logit_bias" type="map[string, integer] | null" required={false}>
  Modifies the likelihood of specified tokens appearing in the completion.

  Accepts a JSON object that maps tokens to associated bias values between -100 and 100.
  Mathematically, the bias is added to the logits generated by the model before sampling. The exact effect will vary by model.

  For example, setting `"logit_bias":{"1024": 6}` will increase the likelihood of tokens with token ID 1024.
</ParamField>

<ParamField body="logprobs" type="boolean | null" default={false}>
  Whether to return the log probabilities of output tokens. If true, the log probability of each output token in the message content is returned.
</ParamField>

<ParamField body="top_logprobs" type="integer | null">
  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. If this parameter is used, `logprobs` must be set to true.

  Required range: `0 <= x <= 20`
</ParamField>

<ParamField body="tools" type="object[] | null">
  A list of tools the model can call. Currently, only functions are supported as tools. Use this to provide a list of functions for which the model can generate JSON inputs.

  Learn more about function calling in the [Function Calling Guide](/en/docs/model/llm-function-calling).

  <Expandable title="Properties" defaultOpen={false}>
    <ParamField body="type" type="string" required={true}>
      The type of the tool.

      Supported type: `function`
    </ParamField>

    <ParamField body="function" type="object" required={true}>
      <Expandable title="Properties" defaultOpen={false}>
        <ParamField body="name" type="string" required={true}>
          The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and hyphens, with a maximum length of 64.
        </ParamField>

        <ParamField body="description" type="string | null">
          A description of the function, used by the model to choose when and how to call the function.
        </ParamField>

        <ParamField body="parameters" type="object | null">
          The parameters accepted by the function, described as a JSON Schema object. For documentation on the format, see the [JSON Schema Reference](https://json-schema.org/understanding-json-schema/).
        </ParamField>

        <ParamField body="strict" type="boolean" default={false}>
          Whether to enable strict schema adherence when generating the function call. If set to true, the model will follow the exact schema defined in the parameters field.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="response_format" type="object | null">
  Allows forcing the model to generate a specific output format.

  Set to `{ "type": "json_schema", "json_schema": {...} }` to enable structured outputs and ensure the model will match the JSON schema you provide.

  Set to `{ "type": "json_object" }` to enable the legacy JSON mode, ensuring that messages generated by the model are valid JSON. For models that support it, `json_schema` is recommended.

  <Expandable title="Properties" defaultOpen={false}>
    <ParamField body="type" type="string" required={true} default="text">
      Enum values: `text`, `json_object`, `json_schema`
    </ParamField>

    <ParamField body="json_schema" type="object | null">
      JSON Schema response format. Used to generate structured JSON responses.

      Supported only when `type` is set to `json_schema`, and required when `type` is set to `json_schema`.

      Learn more in the [Structured Outputs Guide](/en/docs/model/llm-structured-outputs).

      <Expandable title="Properties" defaultOpen={false}>
        <ParamField body="name" type="string" required={true}>
          The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and hyphens, with a maximum length of 64.
        </ParamField>

        <ParamField body="description" type="string | null">
          A description of the response format, used by the model to determine how to respond in that format.
        </ParamField>

        <ParamField body="schema" type="object | null">
          The schema of the response format, described as a JSON Schema object. Learn how to build JSON schema [here](https://json-schema.org/specification).

          Supported types: `string`, `number`, `integer`, `boolean`, `array`, `object`, `enum`, `anyOf`.
        </ParamField>

        <ParamField body="strict" type="boolean" default={false}>
          Whether to enable strict schema adherence when generating outputs. If set to true, the model will always follow the exact schema defined in the schema field. When strict is true, only a subset of JSON Schema is supported.

          If you enable structured outputs by providing `strict: true` and call the API with an unsupported JSON Schema, you will receive an error.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="separate_reasoning" type="boolean | null" default={false}>
  Whether to separate reasoning from "content" into the "reasoning\_content" field.

  Supported models:

  * `deepseek/deepseek-r1-turbo`
</ParamField>

<ParamField body="enable_thinking" type="boolean | null" default={true}>
  Controls switching between thinking and non-thinking modes.

  Supported models:

  * `zai-org/glm-4.5`
</ParamField>

## Response Information

<ResponseField name="choices" type="object[]" required={true}>
  The list of chat completion choices.

  <Expandable title="Properties" defaultOpen={false}>
    <ResponseField name="finish_reason" type="string" required={true}>
      The reason the model stopped generating tokens. "stop" if the model reached a natural stop point or a provided stop sequence; "length" if the maximum number of tokens specified in the request was reached.

      Available options: `stop`, `length`
    </ResponseField>

    <ResponseField name="index" type="integer" required={true}>
      The index of the chat completion choice.
    </ResponseField>

    <ResponseField name="message" type="object" required={true}>
      <Expandable title="Properties" defaultOpen={false}>
        <ResponseField name="role" type="string" required={true}>
          The role of the author of this message.

          Available options: `system`, `user`, `assistant`
        </ResponseField>

        <ResponseField name="content" type="string | null">
          The content of the message.
        </ResponseField>

        <ResponseField name="reasoning_content" type="string | null">
          The content of the reasoning steps.

          <Warning>
            This field is only available when `separate_reasoning` is set to true.
          </Warning>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="created" type="integer" required={true}>
  The Unix time when the response was generated, in seconds.
</ResponseField>

<ResponseField name="id" type="string" required={true}>
  The unique identifier of the response.
</ResponseField>

<ResponseField name="model" type="string" required={true}>
  The model used for the chat completion.
</ResponseField>

<ResponseField name="object" type="string" required={true}>
  The object type, always `chat.completion`.
</ResponseField>

<ResponseField name="usage" type="object">
  Usage statistics.

  For streaming responses, the usage field is included in the last response chunk returned.

  <Expandable title="Properties" defaultOpen={false}>
    <ResponseField name="completion_tokens" type="integer" required={true}>
      The number of tokens in the generated completion.
    </ResponseField>

    <ResponseField name="prompt_tokens" type="integer" required={true}>
      The number of tokens in the prompt.
    </ResponseField>

    <ResponseField name="total_tokens" type="integer" required={true}>
      The total number of tokens used in the request (prompt + completion).
    </ResponseField>
  </Expandable>
</ResponseField>
