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

messagesarrayrequired

Conversation messages.

messages.rolestringrequired

Message role, such as system, user, assistant, or tool.

messages.contentstring | object[]required

Message content. Multimodal models may accept structured content parts.

messages.namestring

Optional participant name.

messages.tool_call_idstring

Tool call ID for tool messages.

modelstringrequired

Model ID.

temperaturenumber

Controls randomness in generated output. Higher values make responses more varied; lower values make responses more deterministic.

top_pnumber

Controls nucleus sampling by limiting token choices to a cumulative probability mass. Lower values make output more focused; higher values allow more variety.

max_completion_tokensinteger

Maximum number of tokens the model may generate in the response.

top_kinteger

Top-k sampling cutoff.

frequency_penaltynumber

Frequency-based repetition penalty.

presence_penaltynumber

Presence-based novelty penalty.

context_lengthinteger

Context window length.

streamboolean

Streaming response flag.

stream_optionsobject

Streaming response configuration.

stream_options.include_usageboolean

Include usage information in the streaming response.

toolsarray

Tool definitions.

tools.typestring

Tool type, usually function.

tools.functionobject

Function definition.

tool_choiceobject

Tool selection policy.

tool_choice.typestring

Tool choice type, such as function.

tool_choice.functionobject

Function selection payload.

parallel_tool_callsboolean

Parallel tool-call flag.

previous_response_idstring

Previous response ID.

conversationobject

Conversation state object or ID.

prompt_cache_keystring

Prompt cache key.

storeboolean

Response storage flag.

truncationstring

Input truncation strategy.

includearray

Additional response fields to include.

metadataobject

Application metadata.

extra_bodyobject

Additional request body fields.

provider_optionsobject

Upstream configuration.

schema_paramsobject

Structured output schema parameters.

network_searchboolean

Network search flag.

reasoningobject

Reasoning control configuration.

reasoning.enabledboolean

Enable reasoning when the selected model supports it.

reasoning.effortstring

Reasoning effort. Supports xhigh, high, medium, low, minimal, and none.

reasoning.max_tokensinteger

Maximum reasoning tokens. Used for execution when supplied with effort.

reasoning.excludeboolean

Reason internally without returning reasoning text.

response_formatstring

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.

usage.prompt_tokensinteger

Input token count when returned.

usage.completion_tokensinteger

Output token count when returned.

usage.total_tokensinteger

Total token count when returned.

usage.input_tokensinteger

Input token count for providers that use input/output names.

usage.output_tokensinteger

Output token count for providers that use input/output names.

usage.generated_imagesinteger

Generated image count when returned.

usage.audio_duration_secondsnumber

Audio duration used for billing when returned.

usage.video_duration_secondsnumber

Video duration used for billing when returned.

usage.provider_request_idstring

Provider request ID used for upstream correlation.

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_completion_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?