跳转到主要内容
POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "glm-5",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself"
      }
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703884800,
  "model": "glm-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm GLM-5, a next-generation large language model developed by Zhipu AI. I feature strong reasoning capabilities and long-context understanding. How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 40,
    "total_tokens": 53
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.toapis.com/llms.txt

Use this file to discover all available pages before exploring further.

  • OpenAI-compatible Chat Completions API
  • Select the glm-5 model via the model parameter
  • Supports streaming output (SSE)
  • Supports multi-turn conversation and system prompts
  • Text-only input; vision input (images) is not supported

Authorizations

Authorization
string
必填
All endpoints require Bearer Token authenticationGet your API Key from the API Key Management PageAdd to request header:
Authorization: Bearer YOUR_API_KEY

Body

model
string
默认值:"glm-5"
必填
Model nameExample: "glm-5"
messages
object[]
必填
List of conversation messages in chronological order
stream
boolean
默认值:false
Whether to enable streaming output (Server-Sent Events)
  • true: Stream tokens incrementally
  • false: Return the complete response at once
max_tokens
integer
Maximum number of tokens to generateUses the model’s default limit when not set
temperature
number
默认值:1
Sampling temperature, controls output randomness
  • Range: 0 to 2
  • Lower values produce more deterministic output; higher values produce more varied output
top_p
number
默认值:1
Nucleus sampling probability thresholdRange: 0 to 1. It is not recommended to modify both temperature and top_p at the same time
stop
string | string[]
Stop sequences — generation stops when these strings are encounteredMaximum 4 stop sequences

Response

id
string
Unique identifier for this request
object
string
Object type, always chat.completion
created
integer
Request creation timestamp (Unix)
model
string
The model that was actually used
choices
object[]
List of generated results
  • choices[].message.role: Message role, always assistant
  • choices[].message.content: Generated text content
  • choices[].finish_reason: Stop reason — stop / length / content_filter
  • choices[].index: Result index
usage
object
Token usage statistics for this request
  • usage.prompt_tokens: Input token count
  • usage.completion_tokens: Output token count
  • usage.total_tokens: Total token count
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "glm-5",
    "messages": [
      {
        "role": "user",
        "content": "Hello, please introduce yourself"
      }
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703884800,
  "model": "glm-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm GLM-5, a next-generation large language model developed by Zhipu AI. I feature strong reasoning capabilities and long-context understanding. How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 13,
    "completion_tokens": 40,
    "total_tokens": 53
  }
}