// api reference
Create chat completion
Generates the model's reply to a conversation. Compatible with OpenAI's Chat Completions API.
POST
https://api.litepod.io/v1/chat/completionsAuthorization
AuthorizationheaderrequiredBearer sk_litepod_.... See Authentication.Request body
modelstringrequiredModel id, e.g.
nvidia/nemotron-lightning-3.5-30b-a3b. See Models.messagesarrayrequiredThe conversation so far, oldest first. Each message has a
role (system, user, assistant or tool) and content: a string, or an array of text and image_url parts for vision. Must not be empty.max_tokensinteger ≥ 1Most tokens to generate. Can't exceed the model's context length. Also sets the wallet reservation (2,048 tokens if omitted).
max_completion_tokens is accepted as an alias; send only one.temperaturenumber, 0–2Sampling temperature. Lower is more focused, higher is more varied.
top_pnumber, 0–1Nucleus sampling. Adjust this or temperature, not both.
ninteger, 1–128Number of choices to generate. Default 1. Each one is billed.
streambooleanstopstring | arrayGeneration stops before any of these strings.
toolsarrayFunctions the model may call. See Function calling.
tool_choicestring | objectauto (default), none, required, or a specific function.response_formatobject{"type": "json_object"} makes the model reply with valid JSON. Ask for JSON in the prompt too.seedintegerBest-effort repeatable sampling.
presence_penalty / frequency_penaltynumber, -2–2Discourage repeating topics or tokens.
Any other OpenAI parameter is passed through to the model unchanged.
Response
| Field | Description |
|---|---|
id | Unique id of the completion. |
choices[].message | The reply: content, plus tool_calls when the model calls a function. |
choices[].message.reasoning_content | Reasoning models only: the model's reasoning before its answer. See Reasoning models. |
choices[].finish_reason | stop (natural end or stop string), length (hit max_tokens) or tool_calls. |
usage | prompt_tokens, completion_tokens and total_tokens: what you're billed for. For reasoning models, completion_tokens_details.reasoning_tokens is the part of completion_tokens spent reasoning. |
Headers include x-request-id and the rate limit headers.
Streaming response
With stream: true, you get chat.completion.chunk events. The last chunk carries usage, then data: [DONE].
Errors
| Status | code | When |
|---|---|---|
| 400 | null / max_tokens_exceeded | Invalid body, empty messages, or max_tokens over the model's context. |
| 401 | invalid_api_key | Missing, malformed or revoked key. |
| 402 | insufficient_balance | Wallet can't cover the reservation. |
| 404 | model_not_found | Unknown or retired model id. |
| 429 | rate_limit_exceeded | Account rate limit reached; see Retry-After. |
| 502 / 503 / 504 | upstream_error / upstream_overloaded / upstream_timeout | The model provider failed, is busy, or timed out. |
See Errors & retries for the error format and what to retry.
curl https://api.litepod.io/v1/chat/completions \
-H "Authorization: Bearer $LITEPOD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nvidia/nemotron-lightning-3.5-30b-a3b",
"messages": [{"role": "user", "content": "Explain RAG in one sentence."}],
"max_tokens": 256
}'200 response
{
"id": "chatcmpl-8f3a2c…",
"object": "chat.completion",
"created": 1790000000,
"model": "nvidia/nemotron-lightning-3.5-30b-a3b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "RAG retrieves relevant documents and gives them to the model so its answer is grounded in them."
},
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 14, "completion_tokens": 21, "total_tokens": 35 }
}text/event-stream
data: {"id":"chatcmpl-8f3a2c…","object":"chat.completion.chunk","model":"nvidia/nemotron-lightning-3.5-30b-a3b","choices":[{"index":0,"delta":{"role":"assistant","content":"RAG"}}]}
data: {"id":"chatcmpl-8f3a2c…","object":"chat.completion.chunk","model":"nvidia/nemotron-lightning-3.5-30b-a3b","choices":[{"index":0,"delta":{"content":" retrieves"}}]}
…
data: {"id":"chatcmpl-8f3a2c…","object":"chat.completion.chunk","model":"nvidia/nemotron-lightning-3.5-30b-a3b","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-8f3a2c…","object":"chat.completion.chunk","model":"nvidia/nemotron-lightning-3.5-30b-a3b","choices":[],"usage":{"prompt_tokens":14,"completion_tokens":21,"total_tokens":35}}
data: [DONE]