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

# Chat Completions Format

> Create a model response based on conversation history. Supports streaming and non-streaming responses. Compatible with the OpenAI Chat Completions API.

When `stream` is set to `true`, the API returns generated content in SSE chunks.

## Headers

**Authorization** `string` *required*

Bearer token authentication. Format: `Authorization: Bearer sk-xxxxxx`

## Body

Format: `application/json`

**model** `string` *required*

Model ID

**messages** `object[]` *required*

List of conversation messages

**Properties**

**role** `string` *required*

Message role. Options: `system`, `user`, `assistant`, `tool`, `developer`

**content** `string | object[]` *required*

Message content

**name** `string`

Sender name

**tool\_calls** `object[]`

List of tool calls

**tool\_call\_id** `string`

Tool call ID (used for `tool` role messages)

**reasoning\_content** `string`

Reasoning content

**temperature** `number` (default: 1)

Sampling temperature, range `0` to `2`

**top\_p** `number` (default: 1)

Nucleus sampling parameter, range `0` to `1`

**n** `integer` (default: 1)

Number of completions to generate, range `1` and above

**stream** `boolean` (default: false)

Whether to stream the response

**stream\_options** `object`

Streaming response options

**Properties**

**include\_usage** `boolean`

Whether to include usage information in the streaming response

**stop** `string | string[]`

Stop sequence(s)

**max\_tokens** `integer`

Maximum number of tokens to generate

**max\_completion\_tokens** `integer`

Maximum number of completion tokens

**presence\_penalty** `number` (default: 0)

Presence penalty, range `-2` to `2`

**frequency\_penalty** `number` (default: 0)

Frequency penalty, range `-2` to `2`

**logit\_bias** `object`

Sampling bias for specified tokens

**Properties**

**\[key: string]** `number`

Key is the token ID, value is the bias amount

**user** `string`

User identifier

**tools** `object[]`

List of tools

**Properties**

**type** `string`

Tool type

**function** `object`

Function definition

**tool\_choice** `string | object`

Tool selection strategy

**Properties (object form)**

**type** `string`

Tool type

**function** `object`

Specify the function to call

**response\_format** `object`

Response format settings

**Properties**

**type** `string`

Format type. Options: `text`, `json_object`, `json_schema`

**json\_schema** `object`

JSON Schema definition

**seed** `integer`

Random seed

**reasoning\_effort** `string`

Reasoning effort (for models that support reasoning). Options: `"low"`, `"medium"`, `"high"`

**modalities** `string[]`

List of modality types

**audio** `object`

Audio parameters

**Properties**

**voice** `string`

Voice

**format** `string`

Audio format

## Response

### 200 Successfully created response

Format: `application/json`

**id** `string`

Completion ID

**object** `string`

Object type, value is `chat.completion`

**created** `integer`

Creation timestamp

**model** `string`

Model ID

**choices** `object[]`

List of generated results

**Properties**

**index** `integer`

Result index

**message** `object`

Message object

**Properties**

**role** `string`

Role

**content** `string`

Content

**name** `string`

Name

**tool\_calls** `array[object]`

List of tool calls

**Properties**

**id** `string`

Call ID

**type** `string`

Type, value is `function`

**function** `object`

Function information

**Properties**

**name** `string`

Function name

**arguments** `string`

Function arguments

**tool\_call\_id** `string`

Tool call ID

**reasoning\_content** `string`

Reasoning content

**finish\_reason** `string`

Finish reason, e.g. `stop`

**usage** `object`

Token usage information

**Properties**

**prompt\_tokens** `integer`

Prompt token count

**completion\_tokens** `integer`

Completion token count

**total\_tokens** `integer`

Total token count

**prompt\_tokens\_details** `object`

Prompt token details

**Properties**

**cached\_tokens** `integer`

Cached token count

**text\_tokens** `integer`

Text token count

**audio\_tokens** `integer`

Audio token count

**image\_tokens** `integer`

Image token count

**completion\_tokens\_details** `object`

Completion token details

**Properties**

**text\_tokens** `integer`

Text token count

**audio\_tokens** `integer`

Audio token count

**reasoning\_tokens** `integer`

Reasoning token count

**system\_fingerprint** `string`

System fingerprint

### 400 Invalid request parameters

Format: `application/json`

**error** `object`

Error information

**Properties**

**message** `string`

Error message

**type** `string`

Error type

**param** `string | null`

Related parameter

**code** `string | null`

Error code

### 429 Rate limit exceeded

Format: `application/json`

**error** `object`

Error information

**Properties**

**message** `string`

Error message

**type** `string`

Error type

**param** `string | null`

Related parameter

**code** `string | null`

Error code

```bash cURL theme={"dark"}
curl -X POST "https://t.ato2.nodesms.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [
      {
        "role": "system",
        "content": "string"
      }
    ]
  }'
```

```python Python theme={"dark"}
import openai

client = openai.OpenAI(
    api_key="sk-xxxxxx",
    base_url="https://t.ato2.nodesms.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "system", "content": "string"}]
)
print(response.choices[0].message.content)
```

```json 200 theme={"dark"}
{
  "id": "string",
  "object": "chat.completion",
  "created": 0,
  "model": "string",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "system",
        "content": "string",
        "name": "string",
        "tool_calls": [
          {
            "id": "string",
            "type": "function",
            "function": {
              "name": "string",
              "arguments": "string"
            }
          }
        ],
        "tool_call_id": "string",
        "reasoning_content": "string"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "text_tokens": 0,
      "audio_tokens": 0,
      "image_tokens": 0
    },
    "completion_tokens_details": {
      "text_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0
    }
  },
  "system_fingerprint": "string"
}
```

```json 400 theme={"dark"}
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}
```

```json 429 theme={"dark"}
{
  "error": {
    "message": "string",
    "type": "string",
    "param": "string",
    "code": "string"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.