Create chat completion

POST/v1/chat/completions

Create a chat completion response for the given conversation.

Authentication

Authorization Bearer

API key as bearer token in Authorization header.

Request Body

modelstringdefault:glm-5.1required

The text model code to call.

Example: "glm-5.1"

messagesMessage[]required

Conversation messages used as the model prompt.

messages.roleenum<string>default:userrequired

Role of the message author.

Available options: system user assistant tool

messages.contentstringrequired

Text content for system, user, assistant, and tool messages.

messages.tool_callsobject[]

Tool calls generated by an assistant message.

messages.tool_call_idstringrequired for tool messages

Tool call ID that a tool message responds to.

temperaturenumberdefault:1

Sampling temperature. Lower values are more deterministic.

Example: 0.7

max_tokensinteger

Maximum number of generated tokens.

streambooleandefault:false

Return Server-Sent Events when true.

top_pnumberdefault:1

Nucleus sampling value.

stopstring | string[]

Stop sequence or sequences.

thinkingobject

Reasoning control, such as {"type":"enabled"}, {"type":"disabled"}, or {"type":"auto"}.

response_formatobject

Structured output format, such as json_object or json_schema.

toolsobject[]

Tool definitions the model may call.

tool_choicestring | objectdefault:auto

Tool selection strategy.

Response

idstring

Unique completion ID.

objectstring

Always chat.completion for non-streaming responses.

createdinteger

Unix timestamp.

modelstring

Model used for the request.

choicesobject[]

Generated choices.

choices.indexinteger

Choice index.

choices.messageobject

Assistant message.

choices.finish_reasonstring

stop, length, or tool_calls.

usageobject

Token usage and cost details.

Request

1curl -X POST https://api.token360.ai/v1/chat/completions \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "model": "glm-5.1",
6    "messages": [
7      {"role": "user", "content": "Reply with the exact text: Hello from Token360."}
8    ],
9    "temperature": 0.1,
10    "max_tokens": 20
11  }'

Response

JSON
1{
2  "id": "your-chat-completion-id",
3  "object": "chat.completion",
4  "created": 1776351874,
5  "model": "glm-5.1",
6  "choices": [
7    {
8      "index": 0,
9      "message": {
10        "role": "assistant",
11        "content": "Hello from Token360."
12      },
13      "finish_reason": "stop"
14    }
15  ],
16  "usage": {
17    "prompt_tokens": 57,
18    "completion_tokens": 7,
19    "total_tokens": 64
20  }
21}
Was this page helpful?