Documentation.
Build with a flexible AI API platform for creating, integrating, and scaling applications.
- Make your first request: from API key to first response.
- Connect coding agents: configure your favorite editors and tools.
Quickstart
nbgate supports OpenAI-compatible Chat Completions and Anthropic-compatible Messages. Use the SDK and request format that fits your application.
- 1Set up an nbgate account with available API quota. Open the dashboard, then create or copy your API key.
- 2Store the key as an environment variable in your terminal. The shell examples on this page use Bash or Zsh (macOS, Linux, or WSL).
export NBGATE_API_KEY="YOUR_NBGATE_API_KEY"$env:NBGATE_API_KEY="YOUR_NBGATE_API_KEY"Then use the Python or Node.js tutorial below. Bash cURL syntax differs from PowerShell.
- Base URL
https://api.nbgate.com/v1- Request limit
- 30–200 RPM by pool tier — milestones in the dashboard
- Protocols
- OpenAI + Anthropic
- Authentication
- Bearer / x-api-key
- Format
- JSON / SSE stream
curl https://api.nbgate.com/v1/chat/completions \
-H "Authorization: Bearer $NBGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Greg/glm-5.3",
"messages": [{"role": "user", "content": "Hello, who are you?"}],
"max_tokens": 256
}'A successful request returns JSON. The model's answer is in choices[0].message.content. If it fails, check the API key and model ID via GET /v1/models, then see Troubleshooting.
Authentication
Every request requires an nbgate API key. OpenAI clients use a Bearer token; Anthropic clients use x-api-key.
Authorization: Bearer YOUR_NBGATE_API_KEYx-api-key: YOUR_NBGATE_API_KEY
anthropic-version: 2023-06-01Top up from $1.00 in USDT (or QRIS) and buy the token quota you need from the dashboard wallet before using paid models.
Run API calls from a backend. Store the key in a server environment variable, never in frontend code or a repository.
Models available
Use the following endpoint to get the current list of active models:
curl https://api.nbgate.com/v1/models \
-H "Authorization: Bearer $NBGATE_API_KEY"Use the id value from data in the model list response. The models below are examples; availability and capabilities vary by account and provider.
Greg/glm-5.3— general-purpose and coding workloads (×2.5 multiplier)Greg/deepseek-v4-flash— fast tier for high-throughput tasks (×2.3 multiplier)Greg/kimi-k2.6— light ×1.5 multiplier for tools and heavy workloads
OpenAI cURL
Standard request:
| Parameter | Description |
|---|---|
model | Required. Model ID from GET /v1/models. |
messages | Required. Message array with role and content; start with a user message. |
max_tokens | Output token limit. Adjust to the model's capability. |
stream | Set true to receive answer chunks over SSE. |
Reasoning models (thinking variants) think before answering. Their internal reasoning tokens are billed as output — a request with max_tokens: 5 can still spend hundreds of tokens while the model reasons, because providers count reasoning as completion. If you only need the final answer, prefer the non-thinking variant of the model.
curl https://api.nbgate.com/v1/chat/completions \
-H "Authorization: Bearer $NBGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Greg/glm-5.3",
"messages": [{"role": "user", "content": "Hello, who are you?"}],
"max_tokens": 256
}'Streaming (Server-Sent Events):
curl -N https://api.nbgate.com/v1/chat/completions \
-H "Authorization: Bearer $NBGATE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Greg/deepseek-v4-flash",
"messages": [{"role": "user", "content": "Tell me about AI"}],
"stream": true
}'The -N flag disables cURL buffering. Read choices[0].delta.content from each data: event; the last event can carry [DONE]. SDKs parse SSE automatically.
OpenAI Python
- 1Install a supported Python, then create a virtual environment so project dependencies stay isolated.
- 2Activate the environment and install the SDK. Make sure NBGATE_API_KEY is set in the same terminal.
python -m venv .venv
source .venv/bin/activate
python -m pip install openaiPowerShell: activate with .venv\Scripts\Activate.ps1. Save the following code as main.py.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NBGATE_API_KEY"],
base_url="https://api.nbgate.com/v1"
)
response = client.chat.completions.create(
model="Greg/glm-5.3",
messages=[{"role": "user", "content": "Hello, who are you?"}],
max_tokens=256
)
print(response.choices[0].message.content)python main.pyThe terminal prints the model's answer. For step-by-step output, replace main.py with the streaming example below and run the same command.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NBGATE_API_KEY"],
base_url="https://api.nbgate.com/v1"
)
stream = client.chat.completions.create(
model="Greg/deepseek-v4-flash",
messages=[{"role": "user", "content": "Explain recursion"}],
stream=True,
max_tokens=512
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)OpenAI Node.js
- 1Install a supported Node.js LTS, then open a new project folder in your terminal.
- 2Initialize the project and install the SDK. Save examples as
main.mjsso imports and top-level await work directly.
npm init -y
npm install openaiimport OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.NBGATE_API_KEY,
baseURL: 'https://api.nbgate.com/v1',
});
const response = await client.chat.completions.create({
model: 'Greg/glm-5.3',
messages: [{ role: 'user', content: 'Hello, who are you?' }],
max_tokens: 256,
});
console.log(response.choices[0].message.content);node main.mjsRun it in the terminal where NBGATE_API_KEY is set. The answer prints to the terminal. Replace main.mjs with the following to try streaming.
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.NBGATE_API_KEY,
baseURL: 'https://api.nbgate.com/v1',
});
const stream = await client.chat.completions.create({
model: 'Greg/deepseek-v4-flash',
messages: [{ role: 'user', content: 'Explain recursion' }],
stream: true,
max_tokens: 512,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}Anthropic API
Compatible with the Anthropic Messages API. POST /v1/messages accepts the Anthropic Messages request and response format and runs on the same nbgate access, quota, rate limit, and billing pipeline.
Use x-api-key and anthropic-version: 2023-06-01. Authorization: Bearer is also accepted for direct HTTP clients.
curl https://api.nbgate.com/v1/messages \
-H "x-api-key: $NBGATE_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "Gregv2/claude-opus-4-6-thinking",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Hello!"}]
}'SDK Anthropic — Python:
pip install anthropicimport os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["NBGATE_API_KEY"],
# The Anthropic SDK adds /v1/messages automatically.
base_url="https://api.nbgate.com"
)
message = client.messages.create(
model="Gregv2/claude-opus-4-6-thinking",
max_tokens=512,
messages=[{"role": "user", "content": "Hello!"}]
)
print(message.content[0].text)The Anthropic SDK automatically appends /v1/messages — set the base URL to the API origin without /v1.
SDK Anthropic — Node.js:
npm install @anthropic-ai/sdkimport Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({
apiKey: process.env.NBGATE_API_KEY,
// The Anthropic SDK adds /v1/messages automatically.
baseURL: 'https://api.nbgate.com',
});
const stream = client.messages.stream({
model: 'Gregv2/claude-opus-4-6-thinking',
max_tokens: 512,
messages: [{ role: 'user', content: 'Explain recursion' }],
});
stream.on('text', text => process.stdout.write(text));
await stream.finalMessage();Tool execution and image understanding depend on the capabilities of the nbgate model you choose.
Connect coding agents
nbgate serves standard API endpoints so coding agents work directly without a custom adapter. Store the API key in the client's environment or secret store, then pick a model available to your account.
Claude Code
Claude Code uses the Anthropic Messages API. Set the API origin without /v1 — the CLI appends the messages path automatically.
- 1Install Claude Code per its official guide, then verify
claude --versionsucceeds. - 2Set the base URL and API key in the same terminal, open a project folder, then run the command below.
- 3Send a short prompt. If authentication fails, check the login configuration or other active tokens in Claude Code.
export ANTHROPIC_BASE_URL=https://api.nbgate.com
export ANTHROPIC_AUTH_TOKEN=YOUR_NBGATE_API_KEY
claude --model Gregv2/claude-opus-4-6-thinkingCursor
In Cursor, open Settings → Models → OpenAI API, enable the OpenAI-compatible provider, then use the nbgate base URL and API key.
- 1Open Cursor Settings and find the Models / API Keys section. Menu names vary by version.
- 2Enter the nbgate key under the OpenAI settings. If available, enable Override OpenAI Base URL and set
https://api.nbgate.com/v1. - 3Add a model ID from GET /v1/models, select it in chat, then send a test message.
If your Cursor version has no custom base URL setting, use an OpenAI-compatible environment variable through a configured provider or gateway.
Hermes Agent
Configure Hermes Agent with an OpenAI-compatible provider. Use the API base URL /v1 and a nbgate model ID.
export OPENAI_API_KEY=YOUR_NBGATE_API_KEY
export OPENAI_BASE_URL=https://api.nbgate.com/v1OpenClaw
Add nbgate as a custom OpenAI-compatible provider. The provider endpoint must end in /v1 and the key must come from a secret or environment variable.
export OPENAI_API_KEY=YOUR_NBGATE_API_KEY
export OPENAI_BASE_URL=https://api.nbgate.com/v1OpenCode
OpenCode supports custom providers via opencode.json. The example uses the OpenAI-compatible adapter and stores the key in NBGATE_API_KEY.
- 1Install OpenCode from the official documentation and set NBGATE_API_KEY as in the Quickstart.
- 2Save the configuration below as
opencode.jsonin the project root. If the file exists, merge the provider block into it. - 3Run opencode, open /models, pick a nbgate model, and send a short prompt to verify the connection.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"nbgate": {
"npm": "@ai-sdk/openai-compatible",
"name": "nbgate",
"options": {
"baseURL": "https://api.nbgate.com/v1",
"apiKey": "{env:NBGATE_API_KEY}"
},
"models": {
"Greg/glm-5.3": { "name": "GLM 5.3" },
"Greg/deepseek-v4-flash": { "name": "DeepSeek v4 Flash" }
}
}
}
}Configuration UIs and option names vary by client version. The stable contract is the base URL, model ID, and authentication header described above. Never commit an API key to a repository.
Troubleshooting
Start from the simplest cURL request. Read the error message in the response before changing SDK or editor configuration.
| Code | Meaning | What to do |
|---|---|---|
400 / 422 | Invalid request format | Check the JSON, model, messages, and parameters the model supports. Start from the minimal Quickstart example. |
401 / 403 | Authentication or access | Make sure the key is active, the headers are correct, and your account has access to the model. Check quota and key permissions per the error message. |
404 | Endpoint or model | Use /v1 for the OpenAI SDK, but the root domain for the Anthropic SDK. Verify the model ID via /v1/models. |
429 | Rate limit or quota | Read the error detail. For rate limits, reduce parallel requests and follow Retry-After when present. If quota is exhausted, check the dashboard — endless retries do not fix it. |
5xx / timeout | Temporary disruption | Retry with increasing backoff and a retry cap. The OpenAI SDK supports timeout and maxRetries. Avoid auto-retrying streams that already emitted output. |
Sources & further reading
This guide adapts the official SDK usage patterns for the nbgate endpoints. The references below document the original SDKs and tools — use the nbgate base URL, key, and model IDs when following their examples. Feature support follows the nbgate implementation and the model you choose.
- OpenAI · Python SDK— Python, streaming, retries & timeouts
- OpenAI · Node.js SDK— JavaScript / TypeScript & error handling
- Anthropic · Python SDK— Messages API & streaming
- Claude Code— LLM gateway configuration
- Cursor— Editor, models & API keys
- Hermes Agent— Installation & provider configuration
- OpenClaw— Setup & model providers
- OpenCode— Custom providers & models