Documentation
Three models, one endpoint, OpenAI-compatible format. Start with free test credit, create your key and integrate over HTTP using the examples below.
https://api.nexichat.ai/v1Introduction
#The Nexi API exposes the same three models that power the chat. A single endpoint, POST https://api.nexichat.ai/v1/chat/{model}, where the model is air, prime or nova.
Requests and responses follow OpenAI's chat completions format. If you already have code written for an OpenAI SDK, change its base_url to https://api.nexichat.ai/v1 and the key, and set model to one of nexi-air-v1, nexi-prime-v1 or nexi-nova-v1: POST https://api.nexichat.ai/v1/chat/completions is the same endpoint, with the model in the body.
The OpenAPI 3.1 specification, with operations, schemas, error codes and how to resolve each, is at https://api.nexichat.ai/v1/openapi.json. Use it to generate a client, or let an agent read the API without this page.
model field in the body. Send that field and it is ignored, with no error and no effect.First request
#Create a key in the console without contacting sales. The first account receives 1.00 € of free test credit, with no initial top-up. Create a key in the console and make the call. Testing uses the production API and consumes that credit; there is no separate sandbox.
curl https://api.nexichat.ai/v1/chat/prime \
-H "Authorization: Bearer nexi_live_..." \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Olá!"}]
}'The response:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1786500000,
"model": "nexi-prime-v1",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Olá! Em que posso ajudar?" },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 12, "completion_tokens": 8, "total_tokens": 20 }
}Authentication
#Send Authorization: Bearer nexi_live_… with every request.
The key is shown once, when you create it. After that only the prefix is visible. Lose it and your only option is to revoke and create another. You can hold several at a time, which makes rotation painless: create the new one, swap it in your code, revoke the old one.
Nexi Code CLI
#Nexi Code is the official NexiChat CLI: work on your local project from the terminal. Install from the website and run nexicode login to connect your account in the browser. This uses your account plan; API keys and API balance are separate.
curl -fsSL https://nexichat.ai/install.sh | bash
nexicode login
nexicode --helpirm https://nexichat.ai/install.ps1 | iex
nexicode login
nexicode --helpModels and pricing
#Prices in euros per million tokens. No subscription: you pay for what you use.
| Model | URL | Input | Output |
|---|---|---|---|
Nexi Air 2 Fast answers, classification, simple tasks. nexi-air-v1 | /chat/air | 0,26 € | 3,10 € |
Nexi Prime 1 The balanced one. Long text, analysis, coding. nexi-prime-v1 | /chat/prime | 1,80 € | 6,20 € |
Nexi Nova 1 Reasoning. Hard problems, maths, planning. nexi-nova-v1 | /chat/nova | 3,20 € | 9,50 € |
Nova's reasoning tokens are billed as output. That is how usage is reported, and it is also why it is the most expensive of the three.
The request
#POST https://api.nexichat.ai/v1/chat/{air|prime|nova} with a JSON body.
| Field | Notes |
|---|---|
messagesarrayrequired | 1 to 200 messages. Each has a role and content. |
streamboolean | Defaults to false. Set true for an SSE response. |
toolsarray | Up to 64 functions the model may ask you to run. |
max_tokensinteger | Cap on the answer, in tokens (4,096 by default). When Air thinks, it is the room for the answer alone: the thinking has a budget of its own. |
temperaturenumber | 0 to 2. Lower is more deterministic; use 0 for classification and extraction. |
top_pnumber | 0 to 1. Samples only from the set of tokens that adds up to this probability. |
top_kinteger | Air only. Samples from the k most likely tokens (-1 or 0 turns it off). |
min_pnumber | Not available: Air uses speculative decoding, which refuses min_p above 0 (0, the model default, is accepted). |
presence_penaltynumber | -2 to 2. Penalises tokens that have already appeared. |
frequency_penaltynumber | -2 to 2. Penalises tokens by how many times they have appeared. |
repetition_penaltynumber | Air only. Above 0 and up to 2. Multiplicative penalty (1 turns it off). |
reasoning_effortstring | How much the model thinks before it answers: off, low, medium, high or max. Omit it and each model keeps its default. |
Reasoning
#reasoning_effort sets how much the model thinks before it answers: off, low, medium, high or max (none and xhigh are accepted too, meaning off and max). The thinking comes back in reasoning_content, apart from content. Leave the field out and each model keeps its default: Air answers without thinking (off) and Nova always thinks. GET https://api.nexichat.ai/v1/models tells you, per model, the levels it accepts and what each really does (reasoning_efforts, reasoning_levels); a level the model does not have is a 400 reasoning_unsupported.
max_tokens does not mean the same thing when the model thinks. On Air, with low, medium or high, max_tokens is the room for the answer alone (4,096 if you leave it out); the thinking has a budget of its own, on top. OpenAI does it differently: its cap covers thinking and answer together, and a long thought eats the answer. Here the thinking never shortens the answer you asked for. With reasoning_effort left out, or off, max_tokens caps the answer as always.| Level (Air) | Effort that runs | Thinking budget |
|---|---|---|
off | no thinking (default) | 0 |
low | low | 512 |
medium | medium | 2,048 |
high | medium | 4,096 |
When the budget runs out the thinking is closed at the end of its last whole sentence and the answer goes on from there; it is never cut off in the middle of a sentence. Air has no real high effort (the model template only has low, medium and xhigh, and xhigh writes answers half as long), so high runs at medium with a larger budget. max is not available on Air for now (it is slower, and its answers are shorter and cite less): it returns 400 reasoning_unsupported.
Billing. Thinking tokens are billed as output, at the output price, like the answer. usage.completion_tokens is thinking plus answer, and usage.completion_tokens_details.reasoning_tokens is the part the model spent thinking (the number the pod reports, not an estimate): the answer is completion_tokens - reasoning_tokens. Reserved balance and the tokens-per-minute window count the thinking budget plus max_tokens and settle on real usage.
Every response to a request with reasoning_effort carries reasoning_effort_applied and thinking_token_budget (and the X-Reasoning-Effort-Applied and X-Thinking-Token-Budget headers): ask for high and you can see it ran at medium. reasoning_budget_exhausted says whether the budget ran out and we closed the thinking for you. Without streaming, a request that runs past 100 s is cut by our edge: to think a lot, use stream.
off cited the law about as well as medium and high did, in less than half the time. Keep off for citations; use medium or high for multi-step reasoning. Other APIs' names for the same control (reasoning, thinking…) return 400 unsupported_parameter.off and 37 % with high: what was missing was knowledge, and more thinking does not create it. With the text of the law in the request, off rose to 88 % and high to 93 %. Send the text of the law before you raise the level. And the medium budget (2,048) closes the thinking in the middle of the arithmetic on deadline-counting questions (4 of 5 in the same pilot): there reasoning_budget_exhausted comes back true; use high, or check the sums in the answer.air is the model the product calls Nexi Air 2; its API id is nexi-air-v1.
Sampling
#temperature, top_p and stop work on every model; presence_penalty and frequency_penalty are passed on too. top_k and repetition_penalty are applied by Air and refused with 400 unsupported_parameter on Prime and Nova, which would ignore them. min_p above 0 is refused on every model (400 unsupported_parameter): the Air pod uses speculative decoding, which does not combine with min_p; min_p: 0, the model default, is accepted. They used to be accepted and dropped without a word (a top_k: 1 at temperature 1.5 was still random).
Send nothing and Air uses its own defaults: temperature 1.0, top_p 0.95, top_k 20, min_p 0, presence_penalty 0, repetition_penalty 1, which are also what the model card recommends for thinking. With reasoning_effort other than off and no values of yours, we send exactly that set. For answers without thinking the card recommends another (temperature 0.7, top_p 0.8, presence_penalty 1.5); off keeps the model defaults unless you send your own.
temperature: 0 (or top_k: 1) with thinking is greedy decoding, which the card advises against because the thinking can loop: it is honoured and flagged in the X-Sampling-Warning header. Every Air response says what applies in X-Sampling-Applied (for example temperature=1;top_p=0.95;top_k=20;min_p=0;presence_penalty=0;repetition_penalty=1).
Stalled requests
#If the model produces nothing for 90 s, the request ends with 504 upstream_stalled (when streaming, an error event with the same code), and phase says where it stopped: ligacao (nothing arrived), pensamento (mid-thought) or resposta (mid-answer). You are billed only for what was generated; retry.
When the GPU provider runs out of balance, or its balance is below the minimum and the pod is off (the serverless fallback costs three times as much and is not used then), the API answers 503 model_unavailable straight away, with Retry-After, instead of leaving the request waiting. GET /api/health?probe=air sends a real one-token request to the model (to the pod only, when it is on). When streaming, the server sends an SSE comment (: keep-alive) after every 10 s without data: clients ignore it, and it does not count as model progress. If you receive nothing at all, not even a comment, for 30 s the connection is dead: cut it and retry instead of waiting minutes. During service updates (deploys) requests in flight get up to 60 s to finish; the ones that run past that get an error event (service_restarting) and [DONE], never an abrupt cut, and new requests in that window get 503 service_restarting with Retry-After.
Messages
#Four roles, each with its own shape.
| role | Shape | What for |
|---|---|---|
system | content | Your instructions. The Nexi identity always comes before them: you can set a persona, a tone and a format, but the model says it is an AI to anyone who asks. |
user | content | What the person wrote. |
assistant | content and/or tool_calls | Previous replies. This is how you give the model history. |
tool | content + tool_call_id | The result of a function you ran. |
Each message accepts up to 200,000 characters. The conversation is stateless: you send the full history with every request, and nothing is stored on Nexi's side.
The response
#The text is in choices[0].message.content. usage carries the token counts, and that is what the cost is computed from, and it matches what you see in the console.
| finish_reason | Means |
|---|---|
stop | The model finished on its own. |
length | Hit max_tokens. The reply is cut off mid-way. |
tool_calls | Waiting for you to run a function. |
x-request-id header. Log it: it is how support finds your exact request, and without it "it failed yesterday afternoon" is impossible to investigate.Streaming
#With "stream": true the response is SSE: data: lines in OpenAI's format, ending with data: [DONE]. The text arrives in choices[0].delta.content.
data: {"object":"chat.completion.chunk",
"choices":[{"index":0,"delta":{"content":"Olá"}}]}
data: {"object":"chat.completion.chunk",
"choices":[{"index":0,"delta":{"content":"!"}}]}
data: [DONE]curl https://api.nexichat.ai/v1/chat/nova \
-H "Authorization: Bearer nexi_live_..." \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Explica a relatividade"}],
"stream": true
}' --no-buffer--no-buffer with curl, stream=True with requests). Without it everything arrives at once at the end and streaming buys you nothing, the single most common complaint from people wiring up SSE for the first time.Tools
#The model can ask you to run your own functions. It takes three steps, and the middle one is yours: the API never runs your code: it returns the request, you run the function, you send the result back.
curl https://api.nexichat.ai/v1/chat/prime \
-H "Authorization: Bearer nexi_live_..." \
-H "Content-Type: application/json" \
-d '{
"messages": [{"role": "user", "content": "Que tempo faz no Porto?"}],
"tools": [{
"type": "function",
"function": {
"name": "meteorologia",
"description": "Tempo atual numa cidade",
"parameters": {
"type": "object",
"properties": {"cidade": {"type": "string"}},
"required": ["cidade"]
}
}
}]
}'tool_call must get its matching role: "tool" reply, with the tool_call_id lining up. A history containing the call but not the result is rejected, and from then on the whole conversation fails, not just that message.List models
#GET https://api.nexichat.ai/v1/models returns the list in OpenAI's format. Handy for populating a picker without hard-coding names in your code.
{
"object": "list",
"data": [
{ "id": "nexi-air-v1", "object": "model", "owned_by": "nexichat" },
{ "id": "nexi-prime-v1", "object": "model", "owned_by": "nexichat" },
{ "id": "nexi-nova-v1", "object": "model", "owned_by": "nexichat" }
]
}Speech
#POST https://api.nexichat.ai/v1/audio/speech turns text into speech with the nexi-voz-1 model: European Portuguese by default, and 20 more languages. The request is OpenAI's /audio/speech, and the response is the audio file itself, not JSON.
The language goes in the optional language field (an ISO 639-1 code such as en or fr; a region such as en-GB is accepted and ignored). pt is always European Portuguese and es Spanish from Spain. Without it, the language is detected from the text, and short or ambiguous text is read as Portuguese: if you know the language, send it. The X-Nexi-Language header says which one was used.
You pay per character of input: €30.00 per million (about €0.027 per minute of speech), and only when audio comes back. Runs of spaces or line breaks count as one character. A request takes up to 1,500 characters; for longer text, split at sentence boundaries and join the files.
curl https://api.nexichat.ai/v1/audio/speech \
-H "Authorization: Bearer nexi_live_..." \
-H "Content-Type: application/json" \
-d '{
"model": "nexi-voz-1",
"input": "Olá! Sou o Nexi. Em que te posso ajudar hoje?",
"voice": "nexi",
"response_format": "mp3"
}' \
--fail --retry 6 --retry-delay 20 \
--output fala.mp3| Field | Notes |
|---|---|
model | nexi-voz-1 |
input | 1–1,500 |
voice | nexi · origem |
language | pt · en · es · fr · de · it · nl · pl · ar · da · el · fi · he · hi · ja · ko · ms · no · sv · sw · tr |
response_format | mp3 · wav · flac · opus · pcm |
seed | 0–2147483647 |
Voices are picked by name: nexi (the default) and origem, the model's stock voice, still experimental. nexi is a native speaker in pt, en, es, fr, de, it, nl, pl; in the other languages it is the stock voice. The API takes no reference audio and does not clone voices; any extra field is rejected. The same text, voice, language and seed give the same audio (the seed used comes back in X-Nexi-Seed).
503 warming_up with Retry-After while it starts (one to four minutes); that request is not billed. OpenAI SDKs retry on their own; if you call the endpoint by hand, retry after that many seconds.All audio is marked as AI-generated: the X-Nexi-AI-Generated: true header, an inaudible watermark and a text tag inside the file. If you publish it, the EU AI Act expects listeners to be told the voice is synthetic.
The reference voices are openly licensed recordings: the Nabu Casa Voice Datasets (CC0) and, in French, the SIWIS French Speech Synthesis Database (P.-E. Honnet, A. Lazaridis, P. N. Garner and J. Yamagishi, Idiap; CC BY 4.0) and, in Greek, Swedish and Finnish, the opening of LibriVox chapters (public domain). Hebrew vowel marks come from DictaBERT-large-char-menaked (Dicta; CC BY 4.0).
Errors
#Always the same shape. code is stable and meant for branching in your code; message is for humans and may change without notice.
{
"error": {
"code": "rate_limit_rpm",
"message": "Rate limit exceeded for your tier."
}
}| HTTP | code | When it happens |
|---|---|---|
| 400 | invalid_request | The body failed validation, or the model refused the request (a parameter it cannot apply, a request larger than its context). The message says which. Retrying the same request will not help. |
| 400 | tools_unsupported | You sent tools to a model that does not support them. |
| 400 | reasoning_unsupported | You asked for a reasoning_effort this model does not have. GET /models lists each one's levels. |
| 401 | invalid_api_key | Key missing, malformed or revoked. |
| 402 | insufficient_balance | Out of balance. Top up in the console. |
| 404 | unknown_model | The model in the URL is not air, prime or nova. |
| 429 | rate_limit_rpm | Requests per minute above your tier. |
| 429 | rate_limit_tpm | Tokens per minute above your tier. |
| 429 | rate_limit_concurrency | Too many requests in flight at once for your tier, and the wait queue could not serve you in time. |
| 429 | overloaded | The model is under heavy demand from all accounts. It is not a limit of yours. |
| 429 | daily_spend_limit_reached | You hit the daily cap you set in the console. |
| 502 | upstream_error | The model failed. Retrying usually works. |
| 503 | service_restarting | The service is restarting (a deployment). Retry in a few seconds. If it happened mid-request, the stream ends with an error event and [DONE], and you are billed only for what was generated. |
| 504 | upstream_stalled | The model produced nothing for 90 s. The phase field says where it stopped: ligacao, pensamento or resposta. You are billed only for what was generated; retry. |
| 503 | model_unavailable | Model temporarily unavailable. |
| 400 | input_too_long | Speech: the text is over the per-request character ceiling. Split it by sentence. |
| 400 | unknown_voice | Speech: the name in voice is not one of our voices. |
| 400 | unsupported_format | Speech: the response_format is not one we support. |
| 400 | unsupported_parameter | A parameter we do not support: speed other than 1 on speech; on chat, reasoning under another API's names (reasoning, thinking…). Use reasoning_effort. |
| 503 | warming_up | Speech: the worker was stopped and is starting. Retry after Retry-After; you were not billed. |
| 504 | timeout | Speech: the audio was not ready in time. Retry, or send less text; you were not billed. |
429 and 502 are worth retrying with exponential backoff. The other 4xx are not: retrying an invalid_request gives the same answer every time.
Rate limits
#Your tier moves up on its own with what the account holds: the higher of your total top-ups and your current balance. No form, no wait. If your integration needs more from day one, talk to us: we can set a minimum tier on the account.
| Tier | Requirement | Requests/min | Tokens/min | Concurrent |
|---|---|---|---|---|
| 1 | below 10 € | 10 | 10 000 | 2 |
| 2 | 10 € to 100 € | 100 | 200 000 | 4 |
| 3 | above 100 € | 500 | 1 000 000 | 8 |
Every request counts towards the per-minute request limit, including those rejected with 429: retrying without waiting only extends the wait. A request rejected for tokens spends no tokens. Before calling the model, the API reserves an estimate of the input plus max_tokens; only real usage counts at the end. A max_tokens sized to the answer you expect fits more requests into the same minute.
Besides the per-minute limits, each key has a number of requests that may be in flight at once. Requests beyond it are not refused straight away: they wait their turn, for up to 30 seconds, and the X-Queue-Ms response header says how long they waited. Only when the expected wait exceeds that does the API answer 429 with rate_limit_concurrency, immediately and with the Retry-After of that estimate. A waiting request reserves neither balance nor tokens, and if you disconnect while it waits you pay nothing.
You can also set a daily spend cap in the console. Once hit, the API returns daily_spend_limit_reached until the next day. It is a safety net against a runaway loop in your code, not a commercial limit.
Authenticated chat responses include RateLimit-Policy and RateLimit: the enforced request and token quotas, remaining allowance and seconds to reset. These are a snapshot; concurrent requests may consume the allowance. Streaming headers include the token reservation for the request, reconciled when it ends.
RateLimit-Policy: "requests";q=10;w=60;qu="requests", "tokens";q=10000;w=60;qu="tokens"
RateLimit: "requests";r=9;t=30, "tokens";r=9000;t=30A 429 error includes Retry-After in seconds and the same value in error.retry_after. Respect that delay for automatic retries. For the daily spend ceiling, you can lower max_tokens, adjust the ceiling in the console, or wait for the next UTC day. For older clients, X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset describe the request window; reset is a Unix timestamp in seconds.
Versions and changes
#The public API uses URL versioning: /v1/chat/prime and /v1/models. The current version is v1. Compatible additions, such as optional fields or new models, may ship in the same version. Clients should ignore unknown response fields. Breaking contract changes require a new major version.
There is no announced retirement date for v1. A migration will be documented here with the new contract, differences and dates before removal. Only endpoints with an announced deprecation will send Deprecation (RFC 9745), and Sunset(RFC 8594) when a retirement date exists. The Link; rel="service-doc" header points to this policy.
Best practices
#| Do this | Why |
|---|---|
| Log the x-request-id | Without it, investigating a request that failed two days ago is impossible. |
| Exponential backoff on 429 | Retrying straight away only makes it worse and counts against the limit again. |
| Honour Retry-After | It says how many seconds until there is room. Coming back earlier gets refused again. |
| Cap your concurrency | A batch of a thousand requests finishes sooner eight at a time than all at once. |
| stream: true for anything a person reads | The first text arrives in about a second, instead of waiting for the whole answer. |
| Set a daily spend cap | A runaway loop in your code costs real money until somebody notices. |
| One key per environment | Revoking the test key must not take production down. |
| Air for the simple things | Classifying, extracting and summarising do not need Nova. The price gap is 6×. |
Ready to start
Create your key and make the first request in under a minute.