Developer Portal

Ship with one key across every model

Authenticate with nx_live_ keys, route OpenAI, Claude, Gemini, and more through a single proxy, stream tokens in real time, and meter spend against your wallet.

Quickstart

  1. Create an account and claim your trial wallet credit at /register.
  2. Generate a secret key in Dashboard → API Keys. Copy the plaintext once — only the SHA-256 hash is stored.
  3. Call POST /api/v1/chat/completions with Authorization: Bearer nx_live_… or x-api-key.
  4. Inspect X-Nexus-Cost-USD / nexus.balanceAfter to track metering.

API reference

POST /api/v1/chat/completions

OpenAI-compatible chat completions with optional SSE streaming.

Headers

  • Authorization: Bearer nx_live_…
  • x-api-key: nx_live_…
  • Content-Type: application/json

Model routing

  • gpt-4o → OpenAI
  • claude-3-5-sonnet → Anthropic
  • llama-3 → compatible upstream
  • Images via /api/v1/images/generations

Body (subset)

{
  "model": "gpt-4o",
  "stream": true,
  "temperature": 0.7,
  "messages": [
    { "role": "system", "content": "…" },
    { "role": "user", "content": "…" }
  ]
}

Code snippets

cURL

copy-ready
curl https://apinexus.io/api/v1/chat/completions \
  -H "Authorization: Bearer nx_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "stream": true,
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Explain rate limits in one sentence." }
    ]
  }'

Python · openai SDK

copy-ready
from openai import OpenAI

client = OpenAI(
    api_key="nx_live_YOUR_KEY",
    base_url="https://apinexus.io/api/v1",
)

stream = client.chat.completions.create(
    model="gpt-4o",
    stream=True,
    messages=[
        {"role": "user", "content": "Hello from API Nexus"},
    ],
)

for chunk in stream:
    delta = chunk.choices[0].delta.content or ""
    print(delta, end="", flush=True)

TypeScript · fetch

copy-ready
const response = await fetch("https://apinexus.io/api/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: "Bearer nx_live_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-3-5-sonnet",
    stream: false,
    messages: [{ role: "user", content: "Ship a haiku about APIs." }],
  }),
});

if (!response.ok) {
  const err = await response.json();
  throw new Error(err.error?.message ?? "Request failed");
}

const data = await response.json();
console.log(data.choices[0].message.content);
console.log(data.nexus); // { tokensUsed, cost, balanceAfter }

Error guide

All API errors return a standardized JSON envelope:

{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Too many requests. Please slow down and try again.",
    "details": { "limit": 60, "retryAfter": 12 }
  },
  "requestId": "…"
}
CodeHTTPMeaning
rate_limit_exceeded429Too many requests for the current window.
insufficient_quota402Wallet balance is exhausted — top up to continue.
INVALID_API_KEY401Missing, malformed, or revoked API key.
VALIDATION_ERROR400Request body failed schema validation.
UPSTREAM_ERROR4xx/5xxProvider upstream rejected or failed the request.
INTERNAL_ERROR500Unexpected platform failure — retry with backoff.
Rate-limit headers
Responses include X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset. Auth routes allow 5 req/min; proxy routes allow 60 req/min per key/IP.
Developer Documentation · API Nexus