Create a chat completion
const url = 'https://api.aderra.ai/v1/chat/completions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"model":"deepseek-v4.1-flash-uncensored","max_tokens":1024,"messages":[{"role":"user","content":"Write a haiku about the sea."}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.aderra.ai/v1/chat/completions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "deepseek-v4.1-flash-uncensored", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Write a haiku about the sea." } ] }'OpenAI Chat Completions. Send the whole conversation in messages; nothing is stored
between requests. Set stream: true for server-sent events: one data: line per chunk,
ending with data: [DONE]. A streamed reply always carries a final chunk with usage
(Aderra sets stream_options.include_usage for you).
Only the fields listed below are forwarded to the model. Anything else is dropped, not
refused. n must be 1.
A request for an -uncensored model may be served on its standard sibling when the
request plainly does not need the unfiltered model (faster and cheaper). The
x-aderra-model-used response header always names the model that answered, and you
pay that model’s price.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
A model id from GET /v1/models.
object
Text, or an array of content parts (text, image_url). Image parts are read only by models whose input_modalities include image.
object
object
Output ceiling, capped at the model’s output limit. Absent (or not a positive integer) means the limit itself. The hold is sized on it.
Same as max_tokens; used when max_tokens is absent.
object
object
object
Thinking budget. Some models think by default: when you set a max_tokens below 16,384 and send no reasoning_effort, reasoning or thinking, Aderra may send minimal for you so the budget goes to the answer.
object
object
object
Must be 1 or absent.
Example
{ "model": "deepseek-v4.1-flash-uncensored", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Write a haiku about the sea." } ]}Responses
Section titled “Responses”The completion. JSON, or text/event-stream when stream is true.
object
object
object
object
object
Includes any thinking tokens.
object
Example
{ "object": "chat.completion"}data: {chat.completion.chunk} lines, then data: [DONE].
Example
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Waves"}}]}
data: {"id":"chatcmpl-1","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":812,"completion_tokens":17,"total_tokens":829}}
data: [DONE]Headers
Section titled “Headers”Example
deepseek-v4.1-flashThe model that actually answered, and the one you are billed for.
Example
kept:not_unfilteredWhy that model answered: kept:<reason>, downgraded-from:<model> or forced-unfiltered.
The id of the credit hold for this call. Quote it when you contact support about a charge.
invalid_json, unknown_model (with the list of known ids), unsupported_n.
object
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": { "type": "billing_error" }}The key is missing, unknown or revoked: {"error": "unauthorized"}.
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": "unauthorized"}api_wallet_empty: the API wallet cannot pay for this request (lower max_tokens or add funds).
key_spend_cap_reached: the key hit its monthly cap. Terminal keys get their plan’s
refusals instead (insufficient_credits, plan_required).
object
Example
{ "error": { "type": "billing_error", "code": "api_wallet_empty", "message": "Your API wallet does not have enough credits for this request. Top up at https://aderra.ai/developers — API keys draw on the API wallet, not your plan." }}account_suspended: the account behind the key is suspended.
object
Example
{ "error": { "type": "billing_error" }}request_too_large: the body is over the size limit.
object
Example
{ "error": { "type": "billing_error" }}rate_limited: the key passed its requests per minute.
too_many_concurrent_requests: the account already has 8 requests in progress.
Wait for Retry-After seconds.
object
Example
{ "error": { "type": "rate_limit_error", "code": "rate_limited", "message": "This API key is limited to 60 requests a minute. Try again in 12 seconds, or raise the key's limit at https://aderra.ai/developers." }}Headers
Section titled “Headers”Example
12Whole seconds to wait before trying again.
The model failed or could not be reached. Not charged. {"error":"upstream_unreachable"} or an upstream_error object whose code is the upstream HTTP status (a number).
object
object
Media and a few early refusals send error as a plain string, sometimes with a message for a person.
object
Example
{ "error": { "type": "upstream_error", "code": 429, "message": "The model is busy right now. Try again in a few seconds." }}overloaded_error: Aderra is busy receiving other large requests. Retry after Retry-After (5) seconds.
object
object
Example
{ "type": "error", "error": { "type": "invalid_request_error" }}Headers
Section titled “Headers”Example
12Whole seconds to wait before trying again.