How to connect
Our gateway is compatible with OpenAI and Anthropic SDKs. Just swap the base_url and use an API key from the dashboard.
https://ai.servernusa.comOpenAI SDK — Python
from openai import OpenAI
client = OpenAI(
base_url="https://ai.servernusa.com/v1",
api_key="sk-...", # API key from dashboard
)
resp = client.chat.completions.create(
model="nusa/mimo-v2.5",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)OpenAI SDK — Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://ai.servernusa.com/v1",
apiKey: "sk-...", // API key from dashboard
});
const resp = await client.chat.completions.create({
model: "nusa/mimo-v2.5",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);Anthropic SDK — Python
from anthropic import Anthropic
client = Anthropic(
base_url="https://ai.servernusa.com",
api_key="sk-...", # API key from dashboard
)
msg = client.messages.create(
model="nusa/mimo-v2.5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(msg.content[0].text)cURL (streaming)
curl https://ai.servernusa.com/v1/chat/completions \
-H "Authorization: Bearer sk-..." \
-H "Content-Type: application/json" \
-d '{
"model": "nusa/mimo-v2.5",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'Errors
Gateway returns OpenAI- or Anthropic-shaped JSON errors so SDKs and agents (OpenClaw, Hermes, etc.) handle them like native provider errors. On /v1/chat/completions use the OpenAI body; on /v1/messages use the Anthropic body. Rejected preflight requests (auth, balance, context) are not charged.
| HTTP | code | type | Meaning | What to do |
|---|---|---|---|---|
| 400 | context_length_exceeded | invalid_request_error | Input (+ reserved output) exceeds the model context window. Rejected before upstream. | Shorten history, compact/summarize the agent session, start a new session, or pick a model with a larger context. Charge is not applied. |
| 401 | invalid_api_key | authentication_error | Missing, malformed, or invalid API key. | Send Authorization: Bearer <key> with a key from the dashboard. |
| 402 | insufficient_quota | insufficient_quota | Wallet / credit balance cannot cover the worst-case cost of this request. | Top up wallet balance, then retry. |
| 402 | spending_limit_reached | insufficient_quota | This API key hit its spending limit. | Raise or clear the key spending limit, or use another key. |
| 403 | — | permission_error | Account suspended or inactive. | Contact support / check account status. |
| 404 | model_not_found | invalid_request_error | Model id does not exist or is not available. | Call GET /v1/models and use a listed public id (e.g. nusa/mimo-v2.5). |
| 429 | rate_limit_exceeded | rate_limit_error | Too many requests for this key / account (your ServerNusa rate limit). | Slow down, backoff, retry later. |
| 502 | model_unavailable | api_error | This model cannot be served right now (upstream failure). Internal details are never exposed. | Try another model from the catalog, or retry shortly. Not charged. |
| 503 | model_busy | api_error | This model is temporarily busy (capacity / overload). Internal pool or account details are never exposed. | Wait a moment and retry, or switch to another model. Not charged. |
Context length exceeded
Agents often resend full chat history each turn. When estimated input tokens plus the reserved output budget exceed the model's context window, the gateway returns HTTP 400 with context_length_exceeded and does not call upstream. Rotating provider accounts does not increase context — start a compact/summary or a new session with a smaller history.
{
"error": {
"message": "This model's maximum context length is 128000 tokens. Your request estimated ~1080298 tokens.",
"type": "invalid_request_error",
"param": null,
"code": "context_length_exceeded"
}
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "This model's maximum context length is 128000 tokens. Your request estimated ~1080298 tokens."
}
}Busy / unavailable models
If capacity is full or a backend path fails, the gateway returns a clean model_busy (503) or model_unavailable (502). You will not see raw upstream account-pool or provider errors. Prefer switching model rather than retrying the same id indefinitely.
{
"error": {
"message": "This model is temporarily busy. Please try again in a moment or switch to another model.",
"type": "api_error",
"param": null,
"code": "model_busy"
}
}See models and pricing on the models page. Billing is based on actual tokens and deducted from your wallet balance. Context / auth / quota / busy rejections before a successful completion are free.