> ## 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 Tool Assisted Chat Completions Chunk Object

> Schema reference for the streamed tool-assisted chat completions chunk object from Friendli Model APIs during tool-augmented generation.

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

<Info>
  This API is currently in **Beta**.
  While we strive to provide a stable and reliable experience, this feature is still under active development.
  As a result, you may encounter unexpected behavior or limitations.
  We encourage you to provide feedback to help us improve the feature before its official release.

  * [Feature request & feedback](mailto:support@friendli.ai)
  * [Contact support](mailto:support@friendli.ai)
</Info>

<ResponseExample>
  ```json Response theme={null}
  event: tool_status
  data: {
    "tool_call_id": "call_3QrfStXSU6fGdOGPcETocIAq",
    "name": "math:calculator",
    "status": "STARTED",
    "parameters": [{ "name": "expression", "value": "150 * 1.60934" }],
    "result": null,
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726277121
  }

  event: tool_status
  data: {
    "tool_call_id": "call_3QrfStXSU6fGdOGPcETocIAq",
    "name": "math:calculator",
    "status": "ENDED",
    "parameters": [{ "name": "expression", "value": "150 * 1.60934" }],
    "result": "\"{\\\"result\\\": \\\"150 * 1.60934=241.401000000000\\\"}\"",
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726277121
  }

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

  ...

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

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

  data: [DONE]
  ```

  ```json Multiple tools theme={null}
  event: tool_status
  data: {
    "tool_call_id": "call_5X9KQ52bV3CUigqHWleTzD9A",
    "name": "code:python-interpreter",
    "status": "STARTED",
    "parameters": [{ "name": "code", "value": "def is_prime(n): ... \n" }],
    "result": null,
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726277008
  }

  event: tool_status
  data: {
    "tool_call_id": "call_5X9KQ52bV3CUigqHWleTzD9A",
    "name": "code:python-interpreter",
    "status": "ENDED",
    "parameters": [{ "name": "code", "value": "def is_prime(n): ... \n" }],
    "result": "\"[2, 3, 5, 7, 11, 13, 17]\\n\"",
    "files": [],
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726277011
  }

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

  ...

  event: tool_status
  data: {
    "tool_call_id": "call_FgfZYpRoDdPtz3QwLrLZIhdP",
    "name": "math:calculator",
    "status": "STARTED",
    "parameters": [{ "name": "expression", "value": "2 * 3 * 5 * 7 * 11 * 13 * 17" }],
    "result": null,
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726277012
  }

  event: tool_status
  data: {
    "tool_call_id": "call_FgfZYpRoDdPtz3QwLrLZIhdP",
    "name": "math:calculator",
    "status": "ENDED",
    "parameters": [{ "name": "expression", "value": "2 * 3 * 5 * 7 * 11 * 13 * 17" }],
    "result": "\"{\\\"result\\\": \\\"2 * 3 * 5 * 7 * 11 * 13 * 17=510510\\\"}\"",
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726277016
  }

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

  ...

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

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

  data: [DONE]
  ```

  ```json With custom tool theme={null}
  event: tool_status
  data: {
    "tool_call_id": "call_iryDFgBCcNoc2ICXuuyZqQUe",
    "name": "web:search",
    "status": "STARTED",
    "parameters": [{ "name": "query", "value": "tallest buildings in the world" }],
    "result": null,
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726294660
  }

  event: tool_status
  data: {
    "tool_call_id": "call_iryDFgBCcNoc2ICXuuyZqQUe",
    "name": "web:search",
    "status": "UPDATING",
    "parameters": [{ "name": "query", "value": "tallest buildings in the world" }],
    "result": "https://en.wikipedia.org/wiki/List_of_tallest_buildings",
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726294666
  }

  ...

  event: tool_status
  data: {
    "tool_call_id": "call_iryDFgBCcNoc2ICXuuyZqQUe",
    "name": "web:search",
    "status": "ENDED",
    "parameters": [{ "name": "query", "value": "tallest buildings in the world" }],
    "result": "['https://en.wikipedia.org/wiki/List_of_tallest_buildings', ...]",
    "files": null,
    "message": null,
    "error": null,
    "usage": null,
    "timestamp": 1726294671
  }

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

  ...

  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_yuvrTUk4O2Uh7Hns5ieUcu1S",
              "type": "function",
              "function": { "name": "func", "arguments": "{\"" }
            }
          ]
        },
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "created": 1726294673
  }

  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
      }
    ],
    "created": 1726294673
  }

  ...

  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
      }
    ],
    "created": 1726294673
  }

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

  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>

## `event: tool_status` Chunk Object

`event: tool_status` tracks the execution progress of built-in tools, such as calculator or web search functions.
It provides real-time updates on their status and results.

<ResponseField name="tool_call_id" type="string" required="true">
  The ID of the tool call.
</ResponseField>

<ResponseField name="name" type="enum<string>" required="true">
  The name of the built-in tool.

  Available options: `linkup:search`, `math:calculator`, `math:statistics`, `math:calendar`, `web:search`, `web:url`, `code:python-interpreter`, `file:text`
</ResponseField>

<ResponseField name="status" type="enum<string>" required="true">
  Indicates the current execution status of the tool.

  Available options: `STARTED`, `UPDATING`, `ENDED`, `ERRORED`
</ResponseField>

<ResponseField name="parameters" type="object[]" required="true">
  <Expandable title="child attributes">
    <ResponseField name="name" type="string" required="true">
      The name of the tool's function parameter.
    </ResponseField>

    <ResponseField name="value" type="string" required="true">
      The value of the tool's function parameter.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="result" type="string | null">
  The output from the tool's execution.
</ResponseField>

<ResponseField name="files" type="object[] | null">
  <Expandable title="child attributes">
    <ResponseField name="name" type="string" required="true">
      The name of the file generated by the tool's execution.
    </ResponseField>

    <ResponseField name="url" type="string" required="true">
      URL of the file generated by the tool's execution.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="message" type="string | null">
  Message generated by the tool's execution.
</ResponseField>

<ResponseField name="error" type="object | null">
  <Expandable title="child attributes">
    <ResponseField name="type" type="string" required="true">
      The type of error encountered during the tool's execution.
    </ResponseField>

    <ResponseField name="msg" type="string" required="true">
      The message of error.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="timestamp" type="number" required="true">
  The Unix timestamp (in seconds) for when the event occurred.
</ResponseField>
