Integrate in minutes.
NusaGate is compatible with the OpenAI API: change the baseURL, use any official SDK, and pay per token, billed in rupiah. Every example on this page runs as written.
Entry gate
Base URL
Want to code from the terminal right away? NusaCode, NusaGate's official coding agent, connects with no configuration.
Install NusaCodeYour first request
Two steps: create an API key in the dashboard, then send a request to the gateway. There is no special SDK to install.
curl https://api.nusagate.com/v1/chat/completions \
-H "Authorization: Bearer nsk_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3-flash",
"messages": [
{ "role": "user", "content": "Hello, introduce yourself!" }
]
}'The official OpenAI SDKs (JavaScript and Python) work as is. Just point baseURL to https://api.nusagate.com/v1 and apiKey to your nsk_ key.
Rather start coding from the terminal? NusaCode, NusaGate's official coding agent, only asks for your API key on first run.
Available models
Use the ID in the first column as the value of the model field in the request body. Prices are per 1M tokens, prepaid in rupiah. Your code can fetch the same catalog from GET /v1/models.
| Model ID | Input | Context | Input /1M | Output /1M | Cache hit /1M |
|---|---|---|---|---|---|
GPT 6.1 Sol | Input: Text, Image, Audio, Video | 1.05M tokens | $0.56 | $3.33 | $0.0610% of input |
GPT-6 Sol | Input: Text, Image, Audio, Video | 1.05M tokens | $0.69 | $3.44 | $0.0710% of input |
GPT 6 Luna | Input: Text, Image | 1.05M tokens | $0.03 | $0.17 | $0.006720% of input |
GLM 5.3 Flash A 1M multimodal model for coding and agent workflows. | Input: Text, Image, Video | 1.05M tokens | $0.06 | $0.17 | $0.0120% of input |
DeepSeek V4.1 Flash 1M context for coding, RAG, and high-volume processing. | Input: Text, Image | 1.05M tokens | $0.07 | $0.22 | $0.007210% of input |
GPT-5.6 Luna A budget model for high-volume agent workflows. | Input: Text, Image, Video | 1.05M tokens | $0.07 | $0.50 | $0.006710% of input |
GPT-5.6 Terra A balance of quality, reasoning, and cost. | Input: Text, Image | 1.05M tokens | $0.83 | $3.61 | $0.0810% of input |
GPT-5.6 Sol The flagship for complex work and long-horizon agents. | Input: Text, Image, Audio, Video | 1.05M tokens | $1.94 | $5.56 | $0.2915% of input |
Qwen 3.8 Flash | Input: Text, Image | 1.05M tokens | $0.05 | $0.16 | $0.00510% of input |
MiniMax M3.1 Flash | Input: Text, Image | 1.05M tokens | $0.13 | $0.46 | $0.0110% of input |
Qwen 3.8 27B | Input: Text | 131K tokens | $0.06 | $0.56 | $0.005610% of input |
DeepSeek V4 Pro | Input: Text | 1.05M tokens | $0.22 | $0.67 | $0.0210% of input |
MiniMax M3 | Input: Text, Image, Video | 1.05M tokens | $0.25 | $1.00 | $0.0310% of input |
Gemini 3.8 Flash | Input: Text, Image | 1.05M tokens | $0.29 | $1.11 | $0.0310% of input |
GLM 5.3 | Input: Text | 1.05M tokens | $0.46 | $1.44 | $0.0510% of input |
Grok 4.7 | Input: Text, Image | 1.05M tokens | $0.56 | $1.42 | $0.0610% of input |
Qwen 3.8 Max | Input: Text | 131K tokens | $0.66 | $1.97 | $0.0710% of input |
Qwen 3.8 Max 0902 | Input: Text, Image | 1.05M tokens | $0.66 | $1.97 | $0.0710% of input |
GPT 6.1 Terra | Input: Text, Image | 1.05M tokens | $0.67 | $2.22 | $0.2030% of input |
Kimi K3 | Input: Text, Image | 1.05M tokens | $0.94 | $4.94 | $0.0910% of input |
Kimi K3.1 Pro | Input: Text, Image | 1.05M tokens | $1.67 | $8.33 | $0.1710% of input |
GPT-6 Astra | Input: Text, Image, Audio, Video | 272K tokens | $3.33 | $17.22 | $0.3310% of input |
Live prices from the NusaGate catalog, the same as what your account is charged (cached for 1 minute). Models with a cache price support prompt/prefix caching: cached tokens are billed at the percentage shown in the last column.
USD amounts are converted from rupiah at a fixed rate of Rp 18.000 per $1 and are for display only. You are always billed in rupiah.
Authentication & API keys
One key works for every model. Keys are hashed before they are stored, so a database leak does not expose customer keys.
Sign up and create an API key
Sign up, open API keys in the dashboard, and create a new key. Keys start withnsk_and are shown only once when created, so store the key in a secret manager right away.Send it in a header
Include the following header in every request. Never put the API key in a URL, a request body, or frontend code that the browser can read.
Authorization: Bearer nsk_xxxxxxxx...Top up and track usage
Top up your balance in the dashboard with USDC on Solana or Indonesian payment methods. The balance is credited automatically after payment. Every request is logged on the usage page, broken down by model and day.
An empty balance returns 402insufficient_balance, not 500.
Chat Completions
POST /v1/chat/completions accepts an OpenAI-style body. Every optional parameter falls back to the model default when you omit it.
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | required | Model ID. Get the full list from GET /v1/models, for example glm-5.3-flash or gpt-5.6-luna. |
messages | array | required | Conversation history as { role, content } objects. The role can be system, user, or assistant. |
stream | boolean | optional | Defaults to false. When true, the response is sent as Server-Sent Events. |
temperature | number | optional | How creative the answer is, from 0 to 2. Defaults to the model's own default. |
max_tokens | integer | optional | Maximum number of tokens in the answer. |
Streaming example
curl https://api.nusagate.com/v1/chat/completions \
-H "Authorization: Bearer nsk_your_key" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3-flash",
"messages": [
{ "role": "user", "content": "Write a three-line poem about rain." }
],
"stream": true
}'Endpoint Reference
Public gateway endpoints that follow the OpenAI format and can be called directly from your application.
Gateway API
Public endpoints for requests from your application. Authenticate with an nsk_... API key in the Authorization: Bearer header.
Set up your coding agent
The fastest path is NusaCode, NusaGate's official coding agent. For other agents, one helper command points them at NusaGate. Manual configuration is at the end as a fallback.
NusaCode, NusaGate's official coding agent
A coding agent for your terminal, free and open source (MIT license), built on pi. No configuration: on first run NusaCode asks for your NusaGate API key, then you just type what you want done. Every response shows its cost in rupiah.
Needs Node.js 22.19 or newer. The first run asks for your API key and offers to import skills from other coding agents.
/budget 5000- The agent stops at Rp 5.000 for this session, with a warning at 80%.
/model- Open the live NusaGate model catalog and switch model.
/plan- Plan mode: the agent can read but not change anything.
/undo- Put back the files the agent changed in its last prompt.
/usage- This session's cost, tokens, cache hit rate, speed and balance.
/skills review- Skills learned from your work load only after you approve them.
Other agents: one helper command
One command points your coding agent at NusaGate. The helper merges its changes into your configuration and backs up the old file, so your other settings are kept.
# wizard: pick an agent and a model, the key is verified first
npx @nusagate-gateway/helper
# no prompts
npx @nusagate-gateway/helper apply -k nsk_... -m gpt-6.1-sol --agents claude,opencode -y
# which agents already point at NusaGate
npx @nusagate-gateway/helper status
# verify the API key with GET /v1/models, then list the models
npx @nusagate-gateway/helper validate
# list the supported agents
npx @nusagate-gateway/helper list
# remove only the NusaGate settings, leave the rest alone
npx @nusagate-gateway/helper resetSupported agents
- Claude Code
- Codex
- OpenCode
- Cline
- OpenClaw
Hermes
- OMP
- Pi
Helper options
| Option | What it does |
|---|---|
-k, --key <key> | Your NusaGate API key. Can also be read from the NUSAGATE_API_KEY env var. |
--base-url <url> | Defaults to https://api.nusagate.com/v1. |
-m, --model <id> | Main model that agent uses. |
--subagent-model <id> | Model used for subagents and small-fast tasks. |
--models <a,b> | Extra models, used by OpenCode, OpenClaw, OMP, and Pi. |
--all-models | Register every model in the catalog, not only the ones named. |
--agents <sel> | installed (default), all, or a comma-separated list: claude, codex, opencode, cline, openclaw, hermes, omp, pi. |
--dry-run | Show what would change without writing files. |
-y, --yes | Skip the confirmation prompt. |
--json | Print JSON output. |
-h, --help | Show the full help text. |
GET /v1/models before writing anything, and cancels the write if a config file can't be read. A copy of the old file is kept as *.nusagate-backup.Watch: set up NusaGate in OpenCode (2 minutes)
Manual configuration (without the helper)
OpenCode
Save this configuration in ~/.config/opencode/opencode.json. Use NusaGate's public model IDs. Don't add limit if the output limit isn't certain, because OpenCode rejects a limit block that only has context.
export NUSAGATE_API_KEY="nsk_..."
# ~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"model": "nusagate/gpt-6.1-sol",
"provider": {
"nusagate": {
"npm": "@ai-sdk/openai-compatible",
"name": "NusaGate",
"options": {
"baseURL": "https://api.nusagate.com/v1",
"apiKey": "{env:NUSAGATE_API_KEY}"
},
"models": {
"gpt-6.1-sol": { "name": "GPT Sol 6.1" }
}
}
}
}Restart OpenCode after changing the environment variable, then choose the model nusagate/gpt-6.1-sol.
Hermes
Point Hermes's model configuration at the same base URL. Field names can differ between Hermes versions, but the values stay the same.
export NUSAGATE_API_KEY="nsk_..."
export OPENAI_BASE_URL="https://api.nusagate.com/v1"
export OPENAI_MODEL="deepseek-v4.1-flash"
hermes --provider openai-compatibleIf Hermes uses a config file, copy the values of OPENAI_BASE_URL and OPENAI_MODEL into it.
Error contract
Every error uses the OpenAI format { error: { message, type, code, request_id } } with a clear HTTP status, so the OpenAI SDKs, OpenCode and other tools show the message, and retries and alerting can be automated. Branch on error.code. Quote error.request_id when you contact support.
| Status | Error code | Meaning | What to do |
|---|---|---|---|
| 400 | validation_error | The request body is invalid, for example an empty messages array. | The message says what to fix (the same list is in error.details). |
| 400 | context_length_exceeded | The conversation plus the reserved output does not fit in the model's context window. | Compact or shorten the conversation (OpenCode does this on its own), or lower max_tokens. |
| 401 | invalid_api_key | The API key is wrong or revoked, or the Authorization header is missing. | Create a new key in the dashboard and check the Bearer header format. |
| 402 | insufficient_balance | The prepaid balance is used up. | Top up from the dashboard. The balance becomes active once the payment is verified. |
| 404 | model_not_found | The model id is not in the catalog. | Get the official ids from GET /v1/models. |
| 429 | rate_limit | More than 150 requests per minute per account. | Wait as long as retry_after says before trying again. |
| 429 | pass_window_cap | Coding Plan usage reached the per-window limit (only the Pro and Month tiers have limits). | Your plan value stays valid and can be used again once the window resets (see retry_after). If you don't want to wait, turn on the "Continue with balance when the plan limit is reached" option in the dashboard under Wallet, Plan tab, so requests keep going and are paid from your balance. |
| 503 | upstream_busy | The upstream provider is busy or unavailable. | Retry after retry_after. The gateway has already made one internal retry. |
| 500 | internal_error | An unexpected error on the NusaGate side. | Retry, and if it keeps happening, contact support with the requestId. |
HTTP/1.1 429 Too Many Requests
{
"error": {
"message": "Too many requests. Retry in 60 seconds.",
"type": "rate_limit_error",
"code": "rate_limit",
"param": null,
"request_id": "V1StGXR8_Z5jdHi6B-myT"
},
"message": "Too many requests. Retry in 60 seconds.",
"retry_after": 60
}