Chat Completions
The chat completions endpoint creates a model response from a list of messages.
Endpoint
POST https://api.glbwintk.com/v1/chat/completions
Request
curl https://api.glbwintk.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-id",
"messages": [
{
"role": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Write one sentence about GLBWinTK."
}
],
"temperature": 0.2,
"max_tokens": 80
}'
Message Roles
| Role | Purpose |
|---|---|
system | Sets behavior or instructions for the response. |
user | Contains user input. |
assistant | Represents prior assistant output in a conversation. |
Response Shape
Successful responses use an OpenAI-compatible structure:
{
"id": "chatcmpl-example",
"object": "chat.completion",
"model": "your-model-id",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "GLBWinTK provides one OpenAI-compatible API endpoint for AI applications."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 12,
"total_tokens": 32
}
}
Production Notes
- Start with short prompts while validating a model id.
- Set reasonable
max_tokensvalues for predictable usage. - Log request ids and status codes when diagnosing failures.