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
- Create an account and claim your trial wallet credit at /register.
- Generate a secret key in Dashboard → API Keys. Copy the plaintext once — only the SHA-256 hash is stored.
- Call
POST /api/v1/chat/completionswithAuthorization: Bearer nx_live_…orx-api-key. - Inspect
X-Nexus-Cost-USD/nexus.balanceAfterto 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→ OpenAIclaude-3-5-sonnet→ Anthropicllama-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-readycurl 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-readyfrom 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-readyconst 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": "…"
}| Code | HTTP | Meaning |
|---|---|---|
| rate_limit_exceeded | 429 | Too many requests for the current window. |
| insufficient_quota | 402 | Wallet balance is exhausted — top up to continue. |
| INVALID_API_KEY | 401 | Missing, malformed, or revoked API key. |
| VALIDATION_ERROR | 400 | Request body failed schema validation. |
| UPSTREAM_ERROR | 4xx/5xx | Provider upstream rejected or failed the request. |
| INTERNAL_ERROR | 500 | Unexpected 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.