DocsAPI reference
Chat Completions
The OpenAI Chat Completions shape. Same request, same response, same streaming events, so existing clients work unchanged.
POST/v1/chat/completions
The body is passed to the model provider as is. Velaron.AI reads model, messages, stream and the max-tokens field, checks your balance, and forwards the rest untouched: tools, images, response formats, temperature, whatever your client sends.
curl https://velaron.ai/v1/chat/completions \
-H "Authorization: Bearer sk_••••••••" \
-H "Content-Type: application/json" \
-d '{ "model": "velaron/test", "messages": [{ "role": "user", "content": "hi" }] }'Request#
- model
A model id from
GET /v1/models, such asopenai/gpt-4o, or the built-invelaron/test.- messages
A non-empty array of OpenAI-style messages. Text content is counted by length; each image or file part counts as a flat 1,000 input tokens for the balance check, so one photo never looks like a book.
- stream
truefor server-sent events. See Streaming.- max_tokens · max_completion_tokens
The most output you want. When
max_completion_tokensis present it wins. If your balance cannot cover it, Velaron.AI lowers it to what you can afford before the call goes out. See Pricing and billing.- anything else
Forwarded to the provider unchanged, except for provider-routing fields (
provider,providerOptions,provider_options,models,route,byok), which are removed because they could change what you are billed for.
Response#
The provider's JSON, verbatim, plus two headers: x-vels-credits-charged and x-vels-balance. Failed calls carry neither, because nothing was charged.
HTTP/1.1 200 OK
content-type: application/json
x-vels-credits-charged: 11
x-vels-balance: 4989
x-request-id: 7f1c…
{ "id": "chatcmpl-…", "object": "chat.completion", "model": "openai/gpt-4o",
"choices": [{ "index": 0, "message": { "role": "assistant", "content": "…" }, "finish_reason": "stop" }],
"usage": { "prompt_tokens": 300, "completion_tokens": 500, "total_tokens": 800 } }The echo model#
velaron/test answers on every Velaron.AI server, even one with no AI provider connected. It replies with Velaron.AI test: followed by your last user message, and it is billed by length at $3 in and $15 out per million tokens, like a mid-priced model. It is the fastest way to prove a key works end to end and to watch the billing headers move.
{ "id": "kredit-echo-1758560000000", "object": "chat.completion", "model": "velaron/test",
"choices": [{ "index": 0, "message": { "role": "assistant", "content": "Velaron.AI test: hi" }, "finish_reason": "stop" }] }Before the call goes out#
The gateway checks, in this order, and stops at the first that fails:
- The key is valid and under 60 requests this minute.
- The balance is above zero. At zero or below the answer is
402 insufficient_credits. - The body is JSON with
modeland a non-emptymessagesarray. - The model is a chat model with a known price. Unknown ids are
404 model_not_found. - The balance covers the prompt plus at least 16 output tokens. If it does not, the call is refused with the number of credits it would need.
Only then is the request sent. If the provider cannot be reached, you get 502 provider_unreachable and nothing is charged. If the provider answers with an error of its own, its status and body are relayed to you unchanged, and nothing is charged either.
