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

MethodPathPurpose
POST/v1/chat/completionsChat-style generation, streaming or buffered
POST/v1/embeddingsText embeddings
GET/v1/modelsModels 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

FieldTypeNotes
modelstringRequired. One of the IDs from /v1/models.
messagesarrayRequired. role is system, user, assistant or tool.
temperaturenumber0–2. Defaults to the model’s recommended value.
max_tokensintegerUpper bound on generated tokens.
top_pnumberNucleus sampling. Use either this or temperature, not both aggressively.
stopstring | arrayUp to 4 stop sequences.
streambooleanServer-sent events when true.
toolsarrayFunction 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

StatusCodeMeaning
400invalid_requestMalformed body or unsupported parameter
401invalid_api_keyMissing, revoked or wrong key
402insufficient_creditsBalance exhausted — top up in the console
404model_not_foundModel not enabled for this key
429rate_limit_exceededSlow down; honour Retry-After
500upstream_errorProvider failure — retry with backoff
503model_unavailableModel 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.