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

> Schema reference for the streamed completions chunk object returned by Friendli Model APIs when using the completions streaming API.

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

<ResponseExample>
  ```json Response theme={null}
  data: {
    "id": "cmpl-26a1e10db8544bc3adb488d2d205288b",
    "model": "zai-org/GLM-5.2",
    "object": "text_completion",
    "choices": [
      {
        "index": 0,
        "text": " such",
        "token": 1778,
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "created": 1733382157
  }

  data: {
    "id": "cmpl-26a1e10db8544bc3adb488d2d205288b",
    "model": "zai-org/GLM-5.2",
    "object": "text_completion",
    "choices": [
      {
        "index": 0,
        "text": " as",
        "token": 439,
        "finish_reason": null,
        "logprobs": null
      }
    ],
    "created": 1733382157
  }

  ...

  data: {
    "id": "cmpl-26a1e10db8544bc3adb488d2d205288b",
    "model": "zai-org/GLM-5.2",
    "object": "text_completion",
    "choices": [
      {
        "index": 0,
        "text": "",
        "finish_reason": "length",
        "logprobs": null
      }
    ],
    "created": 1733382157
  }

  data: {
    "id": "cmpl-26a1e10db8544bc3adb488d2d205288b",
    "model": "zai-org/GLM-5.2",
    "object": "text_completion",
    "choices": [],
    "usage": {
      "prompt_tokens": 5,
      "completion_tokens": 10,
      "total_tokens": 15
    },
    "created": 1733382157
  }

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

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

<ResponseField name="object" type="string" required="true">
  The object type, which is always set to `text_completion`.
</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="text" type="string" required="true">
      The text.
    </ResponseField>

    <ResponseField name="token" type="integer | null">
      The token.
    </ResponseField>

    <ResponseField name="finish_reason" type="enum<string> | null">
      Termination condition of the generation.
      `stop` means the API returned the full 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.

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

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

      <Expandable title="child attributes">
        <ResponseField name="text_offset" type="integer[]" required="true">
          The starting character position of each token in the generated text, useful for mapping tokens back to their exact location for detailed analysis.
        </ResponseField>

        <ResponseField name="token_logprobs" type="number[]" required="true">
          The log probabilities of each generated token, indicating the model's confidence in selecting each token.
        </ResponseField>

        <ResponseField name="tokens" type="string[]" required="true">
          A list of individual tokens generated in the completion, representing segments of text such as words or pieces of words.
        </ResponseField>

        <ResponseField name="top_logprobs" type="object[]" required="true">
          A list of dictionaries, where each dictionary represents the top alternative tokens considered by the model at a specific position in the generated text, along with their log probabilities. The number of items in each dictionary matches the value of `logprobs`.
        </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 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>
