Quickstart
The Exa API follows the chat completions format, so the official OpenAI libraries work when you change the base address and the key.
- Create an API key in the console. It is shown once; copy it.
- Add credit (from $5).
- Call the API:
curl https://openwist-poc-iiv3.onrender.com/v1/chat/completions \
-H "Authorization: Bearer $EXA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "exa-sage",
"messages": [
{"role": "system", "content": "You are a patient maths tutor."},
{"role": "user", "content": "Explain why the sum of two odd numbers is even."}
]
}'from openai import OpenAI
client = OpenAI(api_key="exa_sk_...", base_url="https://openwist-poc-iiv3.onrender.com/v1")
reply = client.chat.completions.create(
model="exa-sage",
messages=[
{"role": "system", "content": "You are a patient maths tutor."},
{"role": "user", "content": "Explain why the sum of two odd numbers is even."},
],
)
print(reply.choices[0].message.content)
print(reply.usage.total_tokens, "tokens")import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.EXA_API_KEY, baseURL: "https://openwist-poc-iiv3.onrender.com/v1" });
const stream = await client.chat.completions.create({
model: "exa-sage",
stream: true,
messages: [{ role: "user", content: "Explain why the sum of two odd numbers is even." }],
});
for await (const part of stream) process.stdout.write(part.choices[0]?.delta?.content ?? "");Base address: https://openwist-poc-iiv3.onrender.com/v1
Authentication
Send your key as a bearer token on every request: Authorization: Bearer exa_sk_.... Keys belong to an organisation and are created, limited and revoked in the console.
Models
GET /v1/models lists them.
| Model | Best for |
|---|---|
exa-swift | Fast everyday answers |
exa-sage | Balanced reasoning and writing (default) |
exa-god | Most careful, longest thinking |
Chat completions
POST /v1/chat/completions
| Field | Type | Notes |
|---|---|---|
model | string | One of the models above. Defaults to exa-sage. |
messages | array | Up to 100 messages with roles system, user and assistant. The last must be from the user. Content is text, or a list of text parts. |
stream | boolean | Send the answer as server-sent events as it is written. |
stream_options.include_usage | boolean | Add a final event with token counts. |
max_tokens | integer | Stops the answer after about this many tokens and reports finish_reason: "length". Without it, Exa finishes the answer on its own. |
The response has choices[0].message.content, finish_reason and usage (prompt_tokens, completion_tokens, total_tokens). Tools, web search and file features of the Exa app are not part of the API; the API returns words for the words it is given.
Streaming
Set stream: true. Events are data: {...} lines in the usual chunk format and end with data: [DONE]. If Exa has to continue an answer behind the scenes (for example after a model reaches its own output limit) the words simply keep arriving; you do not need to do anything.
Rate limits
Limits protect your budget and keep Exa fast for everyone. Each is set in the console.
| Limit | Scope | Default |
|---|---|---|
| Tokens per minute | Key | 60,000 |
| Tokens per minute (pool) | Organisation, all keys together | 200,000 |
| Requests per minute | Key | Off |
| Tokens per day | Key, resets at midnight Africa/Nairobi | Off |
| Monthly spend cap | Key and organisation | Off |
Responses carry x-ratelimit-limit-tokens, x-ratelimit-remaining-tokens and, when set, the request equivalents. When a limit stops a call you get a 429 with a Retry-After header in seconds.
Errors
Errors are JSON: {"error": {"message": "...", "type": "...", "code": "..."}}.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | The request is malformed: missing messages, a wrong role, or the last message is not from the user. |
| 401 | invalid_api_key | The key is missing, mistyped or revoked. |
| 402 | insufficient_credit | The organisation has no credit left. |
| 403 | account_suspended | The organisation is suspended. Contact support. |
| 404 | model_not_found | The model name does not exist. |
| 413 | context_length_exceeded | The messages are too long (400,000 characters at most). |
| 429 | rate_limit_tokens / rate_limit_requests / rate_limit_org_tokens | A per-minute limit was reached. Wait for Retry-After seconds. |
| 429 | daily_tokens_reached / monthly_cap_reached / key_monthly_cap_reached | A budget was reached; Retry-After says when it resets. |
| 429 | server_busy | Exa is at full capacity and the waiting line is full. Nothing was charged; retry after Retry-After seconds. |
| 503 | overloaded | Exa could not answer just now. Nothing was charged; retry shortly. |
High-volume guide (classes, exams, events)
Exa is designed so that a busy hour slows answers down a little rather than breaking them. To get the most from it:
- One key per room or class. Limits, usage and revocation then work per room, and one noisy client cannot starve the others.
- Size the limits. Estimate tokens per student per minute (a typical answer is 300 to 800 tokens) and set the key and the organisation pool above the total.
- Always retry 429 and 503. Wait
Retry-Afterseconds plus a random second. The example below does this. - Stream for long answers. Students see words immediately while the rest is written.
- Plan big events. Write to support@openwist.com with the number of students and the date so capacity and priority can be arranged ahead.
import random, time
from openai import OpenAI, RateLimitError, APIStatusError
client = OpenAI(api_key="exa_sk_...", base_url="https://openwist-poc-iiv3.onrender.com/v1", max_retries=0)
def ask(messages, model="exa-sage", tries=6):
for attempt in range(tries):
try:
return client.chat.completions.create(model=model, messages=messages)
except RateLimitError as e: # 429: wait as long as the server says
wait = int(e.response.headers.get("retry-after", 5))
except APIStatusError as e:
if e.status_code not in (500, 502, 503, 504):
raise
wait = int(e.response.headers.get("retry-after", 2 ** attempt))
time.sleep(wait + random.random()) # a little jitter so a whole class does not retry in the same second
raise RuntimeError("Exa stayed busy; try again later")Billing and credit
Your organisation holds a prepaid balance in US dollars. Each successful call is charged by tokens in and out at the model's price. Add credit in the console (card, via Paystack). Failed calls and calls stopped by a limit are free. When the balance is zero, calls return 402 insufficient_credit.