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

# Model APIs Chat Completions Chunk Object

> Schema reference for the streamed chat completions chunk object returned by Friendli Model APIs when streaming is enabled.

Represents a streamed chunk of a chat completions response returned by the model, based on the provided input.

<ResponseExample>
  ```json Response theme={null}
  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": { "role": "assistant", "content": "This" },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294381
  }

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": { "content": " is" },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294381
  }

  ...

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": {},
        "finish_reason": "stop",
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294383
  }

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [],
    "usage": {
      "prompt_tokens": 8,
      "completion_tokens": 4,
      "total_tokens": 12
    },
    "created": 1726294402
  }

  data: [DONE]
  ```

  ```json With tools theme={null}
  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": { "role": "assistant", "content": "This" },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294442
  }

  ...

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": {
          "role": "assistant",
          "tool_calls": [
            {
              "index": 0,
              "id": "call_TARbemDG9CFdwuoaQBTRXiYK",
              "type": "function",
              "function": { "name": "func", "arguments": "{\"" }
            }
          ]
        },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294442
  }

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": {
          "role": "assistant",
          "tool_calls": [
            {
              "index": 0,
              "type": "function",
              "function": { "arguments": "arg" }
            }
          ]
        },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294442
  }

  ...

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": {
          "role": "assistant",
          "tool_calls": [
            {
              "index": 0,
              "type": "function",
              "function": { "arguments": "}" }
            }
          ]
        },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294442
  }

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [
      {
        "index": 0,
        "delta": {},
        "finish_reason": "tool_calls",
        "logprobs": null
      }
    ],
    "usage": null,
    "created": 1726294442
  }

  data: {
    "id": "chatcmpl-4b71d12c86d94e719c7e3984a7bb7941",
    "model": "zai-org/GLM-5.2",
    "object": "chat.completion.chunk",
    "choices": [],
    "usage": {
      "prompt_tokens": 468,
      "completion_tokens": 59,
      "total_tokens": 527
    },
    "created": 1726294443
  }

  data: [DONE]
  ```
</ResponseExample>

<ResponseField name="id" type="string" required="true">
  A unique ID of the chat completion.
</ResponseField>

<ResponseField name="object" type="string" required="true">
  The object type, which is always set to `chat.completion.chunk`.
</ResponseField>

<ResponseField name="model" type="string" required="true">
  The model to generate the completion.
</ResponseField>

<ResponseField name="choices" type="object[]" required="true">
  <Expandable title="child attributes">
    <ResponseField name="index" type="integer" required="true">
      The index of the choice in the list of generated choices.
    </ResponseField>

    <ResponseField name="delta" type="object" required="true">
      <Expandable title="child attributes">
        <ResponseField name="role" type="string | null">
          Role of the generated message author, in this case `assistant`.
        </ResponseField>

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

        <ResponseField name="tool_calls" type="object[] | null">
          <Expandable title="child attributes">
            <ResponseField name="index" type="integer" required="true">
              The index of the tool call being generated.
            </ResponseField>

            <ResponseField name="id" type="string | null">
              The ID of the tool call.
            </ResponseField>

            <ResponseField name="type" type="string" required="true">
              The type of the tool, which is always set to `function`.
            </ResponseField>

            <ResponseField name="function" type="object" required="true">
              <Expandable title="child attributes">
                <ResponseField name="name" type="string | null">
                  The name of the function to call.
                </ResponseField>

                <ResponseField name="arguments" type="string" required="true">
                  The arguments for calling the function, generated by the model in JSON format.
                  Ensure to validate these arguments in your code before invoking the function since the model may not always produce valid JSON.
                </ResponseField>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="finish_reason" type="enum<string> | null">
      Termination condition of the generation.
      `stop` means the API returned the full chat completions generated by the model without running into any limits.
      `length` means the generation exceeded `max_tokens` or the conversation exceeded the max context length.
      `tool_calls` means the API has generated tool calls.

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

    <ResponseField name="logprobs" type="object | null">
      Log probability information for the choice.

      <Expandable title="child attributes">
        <ResponseField name="content" type="object[] | null">
          A list of message content tokens with log probability information.

          <Expandable title="child attributes">
            <ResponseField name="token" type="string" required="true">
              The token.
            </ResponseField>

            <ResponseField name="logprob" type="number" required="true">
              The log probability of this token.
            </ResponseField>

            <ResponseField name="bytes" type="integer[] | null">
              A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
            </ResponseField>

            <ResponseField name="top_logprobs" type="object[]" required="true">
              List of the most likely tokens and their log probability, at this token position.

              <Expandable title="child attributes">
                <ResponseField name="token" type="string" required="true">
                  The token.
                </ResponseField>

                <ResponseField name="logprob" type="number" required="true">
                  The log probability of this token.
                </ResponseField>

                <ResponseField name="bytes" type="integer[] | null">
                  A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.
                </ResponseField>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="usage" type="object | null">
  <Expandable title="child attributes">
    <ResponseField name="prompt_tokens" type="integer" required="true">
      Number of tokens in the prompt.
    </ResponseField>

    <ResponseField name="completion_tokens" type="integer" required="true">
      Number of tokens in the generated chat completions.
    </ResponseField>

    <ResponseField name="total_tokens" type="integer" required="true">
      Total number of tokens used in the request (`prompt_tokens` + `completion_tokens`).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="created" type="integer" required="true">
  The Unix timestamp (in seconds) for when the token is sampled.
</ResponseField>
