/chat/completionsCreate Chat Completion
Creates a model response from conversation history with streaming, tools, and usage accounting.
Dùng khóa API của bạn với Authorization: Bearer sk-xxxx.
Ví dụ request
{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"stream": false
}Ví dụ response
{
"id": "chatcmpl_xxx",
"object": "chat.completion",
"created": 0,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 3,
"total_tokens": 11
}
}curl Example
curl -X POST 'https://costrouter.ai/v1/chat/completions' \
-H 'Authorization: Bearer sk-xxxx'
-H 'Content-Type: application/json'
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"stream": false
}'