API Reference
The Nexra API is OpenAI-compatible: keep your SDK, point base_url at
https://api.nexra.art/v1, and use your Nexra key.
Authentication
Every request carries a bearer token:
Authorization: Bearer $NEXRA_API_KEY
Keys are issued per account and can be scoped to a project with its own budget and rate limit. Never ship a key in client-side code — proxy through your backend.
Endpoints
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/chat/completions | Chat-style generation, streaming or buffered |
| POST | /v1/embeddings | Text embeddings |
| GET | /v1/models | Models available to your key |
Chat completions
curl https://api.nexra.art/v1/chat/completions \
-H "Authorization: Bearer $NEXRA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nexra-standard",
"messages": [
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Explain vector search in two sentences."}
],
"temperature": 0.3,
"max_tokens": 400
}'
Request fields
| Field | Type | Notes |
|---|---|---|
model | string | Required. One of the IDs from /v1/models. |
messages | array | Required. role is system, user, assistant or tool. |
temperature | number | 0–2. Defaults to the model’s recommended value. |
max_tokens | integer | Upper bound on generated tokens. |
top_p | number | Nucleus sampling. Use either this or temperature, not both aggressively. |
stop | string | array | Up to 4 stop sequences. |
stream | boolean | Server-sent events when true. |
tools | array | Function calling, OpenAI schema. |
Response
{
"id": "chatcmpl-9f2a1c",
"object": "chat.completion",
"created": 1767225600,
"model": "nexra-standard",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "Vector search maps text to…"},
"finish_reason": "stop"
}],
"usage": {"prompt_tokens": 42, "completion_tokens": 118, "total_tokens": 160}
}
Streaming
Set "stream": true and read server-sent events. Each chunk carries a delta; the stream ends with [DONE].
data: {"choices":[{"delta":{"content":"Vector"}}]}
data: {"choices":[{"delta":{"content":" search"}}]}
data: [DONE]
Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_request | Malformed body or unsupported parameter |
| 401 | invalid_api_key | Missing, revoked or wrong key |
| 402 | insufficient_credits | Balance exhausted — top up in the console |
| 404 | model_not_found | Model not enabled for this key |
| 429 | rate_limit_exceeded | Slow down; honour Retry-After |
| 500 | upstream_error | Provider failure — retry with backoff |
| 503 | model_unavailable | Model temporarily drained — retry or fall back |
Rate limits
Limits are enforced per key and returned on every response:
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
Retry 429s with exponential backoff and jitter; do not retry 400/401/402.
SDKs
# Python
from openai import OpenAI
client = OpenAI(api_key="YOUR_KEY", base_url="https://api.nexra.art/v1")
// Node
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.NEXRA_API_KEY, baseURL: "https://api.nexra.art/v1" });
Support
Questions: [email protected]. Abuse reports: [email protected]. Usage is governed by our Terms and Acceptable Use Policy.