# Chat

# Completions

## List available chat completion models

`client.chat.completions.models(CompletionModelsParamsquery?, RequestOptionsoptions?): CompletionModelsResponse`

**get** `/v5/chat/completions/models`

Lists the models available for use with /v5/chat/completions.

Results are served directly from the stored inference-models catalog filtered to the chat-completion
model type, not from a live provider probe, so availability reflects the catalog's recorded status.
Pass the optional `model_vendor` query parameter to restrict results to a single vendor. Results are
paginated, and each entry reports the model name, vendor, type, and availability. If the underlying
catalog query fails the endpoint returns an empty list rather than raising an error.

### Parameters

- `query: CompletionModelsParams`

  - `ending_before?: string`

  - `limit?: number`

  - `model_vendor?: InferenceModelVendor`

    - `"openai"`

    - `"cohere"`

    - `"vertex_ai"`

    - `"anthropic"`

    - `"azure"`

    - `"gemini"`

    - `"launch"`

    - `"llmengine"`

    - `"model_zoo"`

    - `"bedrock"`

    - `"xai"`

    - `"fireworks_ai"`

  - `sort_by?: string`

  - `sort_order?: SortOrder`

    - `"asc"`

    - `"desc"`

  - `starting_after?: string`

### Returns

- `CompletionModelsResponse`

  - `items: Array<ModelDefinition>`

    - `model_name: string`

      model name, for example `gpt-4o`

    - `model_type: InferenceModelType`

      model type, for example `chat_completion`

      - `"generic"`

      - `"completion"`

      - `"chat_completion"`

    - `model_vendor: InferenceModelVendor`

      model vendor, for example `openai`

      - `"openai"`

      - `"cohere"`

      - `"vertex_ai"`

      - `"anthropic"`

      - `"azure"`

      - `"gemini"`

      - `"launch"`

      - `"llmengine"`

      - `"model_zoo"`

      - `"bedrock"`

      - `"xai"`

      - `"fireworks_ai"`

    - `model_availability?: InferenceModelAvailability`

      model availability indicating availability status, for example `available`

      - `"unknown"`

      - `"available"`

      - `"unavailable"`

  - `object?: "list"`

    - `"list"`

### Example

```typescript
import SGPClient from 'scale-gp';

const client = new SGPClient({
  accountID: 'My Account ID',
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

const response = await client.chat.completions.models();

console.log(response.items);
```

#### Response

```json
{
  "items": [
    {
      "model_name": "model_name",
      "model_type": "generic",
      "model_vendor": "openai",
      "model_availability": "unknown"
    }
  ],
  "object": "list"
}
```

## Generate OpenAI chat completion from messages

`client.chat.completions.create(CompletionCreateParamsparams, RequestOptionsoptions?): CompletionCreateResponse | Stream<ChatCompletionChunk>`

**post** `/v5/chat/completions`

Generates a chat completion from an OpenAI-style `messages` array.

Use this endpoint for standard messages-based chat inference; use /v5/completions instead when you
have a raw text `prompt` rather than messages, /v5/responses for the OpenAI Responses API contract,
and /v5/inference when the payload does not follow any OpenAI schema. The request accepts the OpenAI
Chat Completions parameters (extra fields are allowed and forwarded), and the model is selected from
`model` given as `vendor/name`; most vendors are served through the litellm proxy gateway, while
OpenAI may use a native gateway. When `stream` is set the response is delivered as server-sent events
of `chat.completion.chunk`; otherwise a single `chat.completion` object is returned. Token usage is
recorded for the account, and for streaming responses it is read from the final chunk.

### Parameters

- `CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming`

  - `CompletionCreateParamsBase`

    - `messages: Array<Record<string, unknown>>`

      Body param: openai standard message format

    - `model: string`

      Body param: model specified as `model_vendor/model`, for example `openai/gpt-4o`

    - `audio?: Record<string, unknown>`

      Body param: Parameters for audio output. Required when audio output is requested with modalities: ['audio'].

    - `frequency_penalty?: number`

      Body param: Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.

    - `function_call?: Record<string, unknown>`

      Body param: Deprecated in favor of tool_choice. Controls which function is called by the model.

    - `functions?: Array<Record<string, unknown>>`

      Body param: Deprecated in favor of tools. A list of functions the model may generate JSON inputs for.

    - `logit_bias?: Record<string, number>`

      Body param: Modify the likelihood of specified tokens appearing in the completion. Maps tokens to bias values from -100 to 100.

    - `logprobs?: boolean`

      Body param: Whether to return log probabilities of the output tokens or not.

    - `max_completion_tokens?: number`

      Body param: An upper bound for the number of tokens that can be generated, including visible output tokens and reasoning tokens.

    - `max_tokens?: number`

      Body param: Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

    - `metadata?: Record<string, string>`

      Body param: Developer-defined tags and values used for filtering completions in the dashboard.

    - `modalities?: Array<string>`

      Body param: Output types that you would like the model to generate for this request.

    - `n?: number`

      Body param: How many chat completion choices to generate for each input message.

    - `parallel_tool_calls?: boolean`

      Body param: Whether to enable parallel function calling during tool use.

    - `prediction?: Record<string, unknown>`

      Body param: Static predicted output content, such as the content of a text file being regenerated.

    - `presence_penalty?: number`

      Body param: Number between -2.0 and 2.0. Positive values penalize tokens based on whether they appear in the text so far.

    - `reasoning_effort?: string`

      Body param: For o1 models only. Constrains effort on reasoning. Values: low, medium, high.

    - `response_format?: Record<string, unknown>`

      Body param: An object specifying the format that the model must output.

    - `seed?: number`

      Body param: If specified, system will attempt to sample deterministically for repeated requests with same seed.

    - `stop?: string | Array<string>`

      Body param: Up to 4 sequences where the API will stop generating further tokens.

      - `string`

      - `Array<string>`

    - `store?: boolean`

      Body param: Whether to store the output for use in model distillation or evals products.

    - `stream?: false`

      Body param: If true, partial message deltas will be sent as server-sent events.

      - `false`

    - `stream_options?: Record<string, unknown>`

      Body param: Options for streaming response. Only set this when stream is true.

    - `temperature?: number`

      Body param: What sampling temperature to use. Higher values make output more random, lower more focused.

    - `tool_choice?: string | Record<string, unknown>`

      Body param: Controls which tool is called by the model. Values: none, auto, required, or specific tool.

      - `string`

      - `Record<string, unknown>`

    - `tools?: Array<Record<string, unknown>>`

      Body param: A list of tools the model may call. Currently, only functions are supported. Max 128 functions.

    - `top_k?: number`

      Body param: Only sample from the top K options for each subsequent token

    - `top_logprobs?: number`

      Body param: Number of most likely tokens to return at each position, with associated log probability.

    - `top_p?: number`

      Body param: Alternative to temperature. Only tokens comprising top_p probability mass are considered.

    - `xOpenAIAPIKey?: string`

      Header param

  - `CompletionCreateParamsNonStreaming extends CompletionCreateParamsBase`

    - `stream?: false`

      Body param: If true, partial message deltas will be sent as server-sent events.

  - `CompletionCreateParamsStreaming extends CompletionCreateParamsBase`

    - `stream: true`

      Body param: If true, partial message deltas will be sent as server-sent events.

      - `true`

### Returns

- `CompletionCreateResponse = ChatCompletion | ChatCompletionChunk`

  - `ChatCompletion`

    - `id: string`

    - `choices: Array<Choice>`

      - `finish_reason: "stop" | "length" | "tool_calls" | 2 more`

        - `"stop"`

        - `"length"`

        - `"tool_calls"`

        - `"content_filter"`

        - `"function_call"`

      - `index: number`

      - `message: Message`

        A chat completion message generated by the model.

        - `role: "assistant"`

          - `"assistant"`

        - `annotations?: Array<Annotation>`

          - `type: "url_citation"`

            - `"url_citation"`

          - `url_citation: URLCitation`

            A URL citation when using web search.

            - `end_index: number`

            - `start_index: number`

            - `title: string`

            - `url: string`

        - `audio?: Audio`

          If the audio output modality is requested, this object contains data
          about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).

          - `id: string`

          - `data: string`

          - `expires_at: number`

          - `transcript: string`

        - `content?: string`

        - `function_call?: FunctionCall`

          Deprecated and replaced by `tool_calls`.

          The name and arguments of a function that should be called, as generated by the model.

          - `arguments: string`

          - `name: string`

        - `refusal?: string`

        - `tool_calls?: Array<ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall>`

          - `ChatCompletionMessageFunctionToolCall`

            A call to a function tool created by the model.

            - `id: string`

            - `function: Function`

              The function that the model called.

              - `arguments: string`

              - `name: string`

            - `type: "function"`

              - `"function"`

          - `ChatCompletionMessageCustomToolCall`

            A call to a custom tool created by the model.

            - `id: string`

            - `custom: Custom`

              The custom tool that the model called.

              - `input: string`

              - `name: string`

            - `type: "custom"`

              - `"custom"`

      - `logprobs?: ChoiceLogprobs`

        Log probability information for the choice.

        - `content?: Array<ChatCompletionTokenLogprob>`

          - `token: string`

          - `logprob: number`

          - `top_logprobs: Array<TopLogprob>`

            - `token: string`

            - `logprob: number`

            - `bytes?: Array<number>`

          - `bytes?: Array<number>`

        - `refusal?: Array<ChatCompletionTokenLogprob>`

          - `token: string`

          - `logprob: number`

          - `top_logprobs: Array<TopLogprob>`

          - `bytes?: Array<number>`

    - `created: number`

    - `model: string`

    - `object?: "chat.completion"`

      - `"chat.completion"`

    - `service_tier?: "auto" | "default" | "flex" | 2 more`

      - `"auto"`

      - `"default"`

      - `"flex"`

      - `"scale"`

      - `"priority"`

    - `system_fingerprint?: string`

    - `usage?: CompletionUsage`

      Usage statistics for the completion request.

      - `completion_tokens: number`

      - `prompt_tokens: number`

      - `total_tokens: number`

      - `completion_tokens_details?: CompletionTokensDetails`

        Breakdown of tokens used in a completion.

        - `accepted_prediction_tokens?: number`

        - `audio_tokens?: number`

        - `reasoning_tokens?: number`

        - `rejected_prediction_tokens?: number`

      - `prompt_tokens_details?: PromptTokensDetails`

        Breakdown of tokens used in the prompt.

        - `audio_tokens?: number`

        - `cached_tokens?: number`

  - `ChatCompletionChunk`

    - `id: string`

    - `choices: Array<Choice>`

      - `delta: Delta`

        A chat completion delta generated by streamed model responses.

        - `content?: string`

        - `function_call?: FunctionCall`

          Deprecated and replaced by `tool_calls`.

          The name and arguments of a function that should be called, as generated by the model.

          - `arguments?: string`

          - `name?: string`

        - `refusal?: string`

        - `role?: "developer" | "system" | "user" | 2 more`

          - `"developer"`

          - `"system"`

          - `"user"`

          - `"assistant"`

          - `"tool"`

        - `tool_calls?: Array<ToolCall>`

          - `index: number`

          - `id?: string`

          - `function?: Function`

            - `arguments?: string`

            - `name?: string`

          - `type?: "function"`

            - `"function"`

      - `index: number`

      - `finish_reason?: "stop" | "length" | "tool_calls" | 2 more`

        - `"stop"`

        - `"length"`

        - `"tool_calls"`

        - `"content_filter"`

        - `"function_call"`

      - `logprobs?: ChoiceLogprobs`

        Log probability information for the choice.

    - `created: number`

    - `model: string`

    - `object?: "chat.completion.chunk"`

      - `"chat.completion.chunk"`

    - `service_tier?: "auto" | "default" | "flex" | 2 more`

      - `"auto"`

      - `"default"`

      - `"flex"`

      - `"scale"`

      - `"priority"`

    - `system_fingerprint?: string`

    - `usage?: CompletionUsage`

      Usage statistics for the completion request.

### Example

```typescript
import SGPClient from 'scale-gp';

const client = new SGPClient({
  accountID: 'My Account ID',
  apiKey: process.env['SGP_API_KEY'], // This is the default and can be omitted
});

const completion = await client.chat.completions.create({
  messages: [{ foo: 'bar' }],
  model: 'model',
});

console.log(completion);
```

#### Response

```json
{
  "id": "id",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "annotations": [
          {
            "type": "url_citation",
            "url_citation": {
              "end_index": 0,
              "start_index": 0,
              "title": "title",
              "url": "url"
            }
          }
        ],
        "audio": {
          "id": "id",
          "data": "data",
          "expires_at": 0,
          "transcript": "transcript"
        },
        "content": "content",
        "function_call": {
          "arguments": "arguments",
          "name": "name"
        },
        "refusal": "refusal",
        "tool_calls": [
          {
            "id": "id",
            "function": {
              "arguments": "arguments",
              "name": "name"
            },
            "type": "function"
          }
        ]
      },
      "logprobs": {
        "content": [
          {
            "token": "token",
            "logprob": 0,
            "top_logprobs": [
              {
                "token": "token",
                "logprob": 0,
                "bytes": [
                  0
                ]
              }
            ],
            "bytes": [
              0
            ]
          }
        ],
        "refusal": [
          {
            "token": "token",
            "logprob": 0,
            "top_logprobs": [
              {
                "token": "token",
                "logprob": 0,
                "bytes": [
                  0
                ]
              }
            ],
            "bytes": [
              0
            ]
          }
        ]
      }
    }
  ],
  "created": 0,
  "model": "model",
  "object": "chat.completion",
  "service_tier": "auto",
  "system_fingerprint": "system_fingerprint",
  "usage": {
    "completion_tokens": 0,
    "prompt_tokens": 0,
    "total_tokens": 0,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    }
  }
}
```

## Domain Types

### Chat Completion

- `ChatCompletion`

  - `id: string`

  - `choices: Array<Choice>`

    - `finish_reason: "stop" | "length" | "tool_calls" | 2 more`

      - `"stop"`

      - `"length"`

      - `"tool_calls"`

      - `"content_filter"`

      - `"function_call"`

    - `index: number`

    - `message: Message`

      A chat completion message generated by the model.

      - `role: "assistant"`

        - `"assistant"`

      - `annotations?: Array<Annotation>`

        - `type: "url_citation"`

          - `"url_citation"`

        - `url_citation: URLCitation`

          A URL citation when using web search.

          - `end_index: number`

          - `start_index: number`

          - `title: string`

          - `url: string`

      - `audio?: Audio`

        If the audio output modality is requested, this object contains data
        about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).

        - `id: string`

        - `data: string`

        - `expires_at: number`

        - `transcript: string`

      - `content?: string`

      - `function_call?: FunctionCall`

        Deprecated and replaced by `tool_calls`.

        The name and arguments of a function that should be called, as generated by the model.

        - `arguments: string`

        - `name: string`

      - `refusal?: string`

      - `tool_calls?: Array<ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall>`

        - `ChatCompletionMessageFunctionToolCall`

          A call to a function tool created by the model.

          - `id: string`

          - `function: Function`

            The function that the model called.

            - `arguments: string`

            - `name: string`

          - `type: "function"`

            - `"function"`

        - `ChatCompletionMessageCustomToolCall`

          A call to a custom tool created by the model.

          - `id: string`

          - `custom: Custom`

            The custom tool that the model called.

            - `input: string`

            - `name: string`

          - `type: "custom"`

            - `"custom"`

    - `logprobs?: ChoiceLogprobs`

      Log probability information for the choice.

      - `content?: Array<ChatCompletionTokenLogprob>`

        - `token: string`

        - `logprob: number`

        - `top_logprobs: Array<TopLogprob>`

          - `token: string`

          - `logprob: number`

          - `bytes?: Array<number>`

        - `bytes?: Array<number>`

      - `refusal?: Array<ChatCompletionTokenLogprob>`

        - `token: string`

        - `logprob: number`

        - `top_logprobs: Array<TopLogprob>`

        - `bytes?: Array<number>`

  - `created: number`

  - `model: string`

  - `object?: "chat.completion"`

    - `"chat.completion"`

  - `service_tier?: "auto" | "default" | "flex" | 2 more`

    - `"auto"`

    - `"default"`

    - `"flex"`

    - `"scale"`

    - `"priority"`

  - `system_fingerprint?: string`

  - `usage?: CompletionUsage`

    Usage statistics for the completion request.

    - `completion_tokens: number`

    - `prompt_tokens: number`

    - `total_tokens: number`

    - `completion_tokens_details?: CompletionTokensDetails`

      Breakdown of tokens used in a completion.

      - `accepted_prediction_tokens?: number`

      - `audio_tokens?: number`

      - `reasoning_tokens?: number`

      - `rejected_prediction_tokens?: number`

    - `prompt_tokens_details?: PromptTokensDetails`

      Breakdown of tokens used in the prompt.

      - `audio_tokens?: number`

      - `cached_tokens?: number`

### Chat Completion Chunk

- `ChatCompletionChunk`

  - `id: string`

  - `choices: Array<Choice>`

    - `delta: Delta`

      A chat completion delta generated by streamed model responses.

      - `content?: string`

      - `function_call?: FunctionCall`

        Deprecated and replaced by `tool_calls`.

        The name and arguments of a function that should be called, as generated by the model.

        - `arguments?: string`

        - `name?: string`

      - `refusal?: string`

      - `role?: "developer" | "system" | "user" | 2 more`

        - `"developer"`

        - `"system"`

        - `"user"`

        - `"assistant"`

        - `"tool"`

      - `tool_calls?: Array<ToolCall>`

        - `index: number`

        - `id?: string`

        - `function?: Function`

          - `arguments?: string`

          - `name?: string`

        - `type?: "function"`

          - `"function"`

    - `index: number`

    - `finish_reason?: "stop" | "length" | "tool_calls" | 2 more`

      - `"stop"`

      - `"length"`

      - `"tool_calls"`

      - `"content_filter"`

      - `"function_call"`

    - `logprobs?: ChoiceLogprobs`

      Log probability information for the choice.

      - `content?: Array<ChatCompletionTokenLogprob>`

        - `token: string`

        - `logprob: number`

        - `top_logprobs: Array<TopLogprob>`

          - `token: string`

          - `logprob: number`

          - `bytes?: Array<number>`

        - `bytes?: Array<number>`

      - `refusal?: Array<ChatCompletionTokenLogprob>`

        - `token: string`

        - `logprob: number`

        - `top_logprobs: Array<TopLogprob>`

        - `bytes?: Array<number>`

  - `created: number`

  - `model: string`

  - `object?: "chat.completion.chunk"`

    - `"chat.completion.chunk"`

  - `service_tier?: "auto" | "default" | "flex" | 2 more`

    - `"auto"`

    - `"default"`

    - `"flex"`

    - `"scale"`

    - `"priority"`

  - `system_fingerprint?: string`

  - `usage?: CompletionUsage`

    Usage statistics for the completion request.

    - `completion_tokens: number`

    - `prompt_tokens: number`

    - `total_tokens: number`

    - `completion_tokens_details?: CompletionTokensDetails`

      Breakdown of tokens used in a completion.

      - `accepted_prediction_tokens?: number`

      - `audio_tokens?: number`

      - `reasoning_tokens?: number`

      - `rejected_prediction_tokens?: number`

    - `prompt_tokens_details?: PromptTokensDetails`

      Breakdown of tokens used in the prompt.

      - `audio_tokens?: number`

      - `cached_tokens?: number`

### Chat Completion Token Logprob

- `ChatCompletionTokenLogprob`

  - `token: string`

  - `logprob: number`

  - `top_logprobs: Array<TopLogprob>`

    - `token: string`

    - `logprob: number`

    - `bytes?: Array<number>`

  - `bytes?: Array<number>`

### Choice Logprobs

- `ChoiceLogprobs`

  Log probability information for the choice.

  - `content?: Array<ChatCompletionTokenLogprob>`

    - `token: string`

    - `logprob: number`

    - `top_logprobs: Array<TopLogprob>`

      - `token: string`

      - `logprob: number`

      - `bytes?: Array<number>`

    - `bytes?: Array<number>`

  - `refusal?: Array<ChatCompletionTokenLogprob>`

    - `token: string`

    - `logprob: number`

    - `top_logprobs: Array<TopLogprob>`

    - `bytes?: Array<number>`

### Inference Model Vendor

- `InferenceModelVendor = "openai" | "cohere" | "vertex_ai" | 9 more`

  - `"openai"`

  - `"cohere"`

  - `"vertex_ai"`

  - `"anthropic"`

  - `"azure"`

  - `"gemini"`

  - `"launch"`

  - `"llmengine"`

  - `"model_zoo"`

  - `"bedrock"`

  - `"xai"`

  - `"fireworks_ai"`

### Model Definition

- `ModelDefinition`

  - `model_name: string`

    model name, for example `gpt-4o`

  - `model_type: InferenceModelType`

    model type, for example `chat_completion`

    - `"generic"`

    - `"completion"`

    - `"chat_completion"`

  - `model_vendor: InferenceModelVendor`

    model vendor, for example `openai`

    - `"openai"`

    - `"cohere"`

    - `"vertex_ai"`

    - `"anthropic"`

    - `"azure"`

    - `"gemini"`

    - `"launch"`

    - `"llmengine"`

    - `"model_zoo"`

    - `"bedrock"`

    - `"xai"`

    - `"fireworks_ai"`

  - `model_availability?: InferenceModelAvailability`

    model availability indicating availability status, for example `available`

    - `"unknown"`

    - `"available"`

    - `"unavailable"`

### Sort Order

- `SortOrder = "asc" | "desc"`

  - `"asc"`

  - `"desc"`

### Completion Models Response

- `CompletionModelsResponse`

  - `items: Array<ModelDefinition>`

    - `model_name: string`

      model name, for example `gpt-4o`

    - `model_type: InferenceModelType`

      model type, for example `chat_completion`

      - `"generic"`

      - `"completion"`

      - `"chat_completion"`

    - `model_vendor: InferenceModelVendor`

      model vendor, for example `openai`

      - `"openai"`

      - `"cohere"`

      - `"vertex_ai"`

      - `"anthropic"`

      - `"azure"`

      - `"gemini"`

      - `"launch"`

      - `"llmengine"`

      - `"model_zoo"`

      - `"bedrock"`

      - `"xai"`

      - `"fireworks_ai"`

    - `model_availability?: InferenceModelAvailability`

      model availability indicating availability status, for example `available`

      - `"unknown"`

      - `"available"`

      - `"unavailable"`

  - `object?: "list"`

    - `"list"`

### Completion Create Response

- `CompletionCreateResponse = ChatCompletion | ChatCompletionChunk`

  - `ChatCompletion`

    - `id: string`

    - `choices: Array<Choice>`

      - `finish_reason: "stop" | "length" | "tool_calls" | 2 more`

        - `"stop"`

        - `"length"`

        - `"tool_calls"`

        - `"content_filter"`

        - `"function_call"`

      - `index: number`

      - `message: Message`

        A chat completion message generated by the model.

        - `role: "assistant"`

          - `"assistant"`

        - `annotations?: Array<Annotation>`

          - `type: "url_citation"`

            - `"url_citation"`

          - `url_citation: URLCitation`

            A URL citation when using web search.

            - `end_index: number`

            - `start_index: number`

            - `title: string`

            - `url: string`

        - `audio?: Audio`

          If the audio output modality is requested, this object contains data
          about the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio).

          - `id: string`

          - `data: string`

          - `expires_at: number`

          - `transcript: string`

        - `content?: string`

        - `function_call?: FunctionCall`

          Deprecated and replaced by `tool_calls`.

          The name and arguments of a function that should be called, as generated by the model.

          - `arguments: string`

          - `name: string`

        - `refusal?: string`

        - `tool_calls?: Array<ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall>`

          - `ChatCompletionMessageFunctionToolCall`

            A call to a function tool created by the model.

            - `id: string`

            - `function: Function`

              The function that the model called.

              - `arguments: string`

              - `name: string`

            - `type: "function"`

              - `"function"`

          - `ChatCompletionMessageCustomToolCall`

            A call to a custom tool created by the model.

            - `id: string`

            - `custom: Custom`

              The custom tool that the model called.

              - `input: string`

              - `name: string`

            - `type: "custom"`

              - `"custom"`

      - `logprobs?: ChoiceLogprobs`

        Log probability information for the choice.

        - `content?: Array<ChatCompletionTokenLogprob>`

          - `token: string`

          - `logprob: number`

          - `top_logprobs: Array<TopLogprob>`

            - `token: string`

            - `logprob: number`

            - `bytes?: Array<number>`

          - `bytes?: Array<number>`

        - `refusal?: Array<ChatCompletionTokenLogprob>`

          - `token: string`

          - `logprob: number`

          - `top_logprobs: Array<TopLogprob>`

          - `bytes?: Array<number>`

    - `created: number`

    - `model: string`

    - `object?: "chat.completion"`

      - `"chat.completion"`

    - `service_tier?: "auto" | "default" | "flex" | 2 more`

      - `"auto"`

      - `"default"`

      - `"flex"`

      - `"scale"`

      - `"priority"`

    - `system_fingerprint?: string`

    - `usage?: CompletionUsage`

      Usage statistics for the completion request.

      - `completion_tokens: number`

      - `prompt_tokens: number`

      - `total_tokens: number`

      - `completion_tokens_details?: CompletionTokensDetails`

        Breakdown of tokens used in a completion.

        - `accepted_prediction_tokens?: number`

        - `audio_tokens?: number`

        - `reasoning_tokens?: number`

        - `rejected_prediction_tokens?: number`

      - `prompt_tokens_details?: PromptTokensDetails`

        Breakdown of tokens used in the prompt.

        - `audio_tokens?: number`

        - `cached_tokens?: number`

  - `ChatCompletionChunk`

    - `id: string`

    - `choices: Array<Choice>`

      - `delta: Delta`

        A chat completion delta generated by streamed model responses.

        - `content?: string`

        - `function_call?: FunctionCall`

          Deprecated and replaced by `tool_calls`.

          The name and arguments of a function that should be called, as generated by the model.

          - `arguments?: string`

          - `name?: string`

        - `refusal?: string`

        - `role?: "developer" | "system" | "user" | 2 more`

          - `"developer"`

          - `"system"`

          - `"user"`

          - `"assistant"`

          - `"tool"`

        - `tool_calls?: Array<ToolCall>`

          - `index: number`

          - `id?: string`

          - `function?: Function`

            - `arguments?: string`

            - `name?: string`

          - `type?: "function"`

            - `"function"`

      - `index: number`

      - `finish_reason?: "stop" | "length" | "tool_calls" | 2 more`

        - `"stop"`

        - `"length"`

        - `"tool_calls"`

        - `"content_filter"`

        - `"function_call"`

      - `logprobs?: ChoiceLogprobs`

        Log probability information for the choice.

    - `created: number`

    - `model: string`

    - `object?: "chat.completion.chunk"`

      - `"chat.completion.chunk"`

    - `service_tier?: "auto" | "default" | "flex" | 2 more`

      - `"auto"`

      - `"default"`

      - `"flex"`

      - `"scale"`

      - `"priority"`

    - `system_fingerprint?: string`

    - `usage?: CompletionUsage`

      Usage statistics for the completion request.
