Goal: send one non-streaming chat completion in about five minutes.
Prerequisites
- API key — create in the console (see API keys).
- Base URL —
https://51kik.com/v1for OpenAI-compatible calls (Base URL and environments). - Model id — list the catalog without auth:
curl -sS "https://51kik.com/v1/models" | head -c 2000
Use an entry's id as model (your catalog may differ).
Step 1 — set environment variables
export API_KEY="YOUR_API_KEY"
export MODEL_ID="YOUR_MODEL_ID_FROM_CATALOG"
Never commit keys. Use secrets in CI (see Configuration from env).
Step 2 — call chat completions
curl -sS "https://51kik.com/v1/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "x-trace-id: quickstart-$(date +%s)" \
-d "{
\"model\": \"$MODEL_ID\",
\"messages\": [{ \"role\": \"user\", \"content\": \"Reply with exactly: ok\" }]
}"
x-trace-id is optional; it helps support and usage correlation (Request correlation).
Step 3 — verify the response
On 200, the body follows OpenAI shape, for example:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"choices": [
{
"message": { "role": "assistant", "content": "ok" },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
Token counts come from the upstream provider.
Common failures
| HTTP | What to check |
|---|---|
| 401 | Missing, wrong, or expired API key |
| 403 | Model not allowed, balance, IP allow list |
| 400 | Invalid JSON or messages / model |
| 429 | Rate limit — back off (Rate limits) |
See Errors for the full matrix.
Next steps
- Streaming: Streaming request
- Reference: Create chat completion
- SDK: Chat and streaming