API Documentation & Atlas Guide
Complete reference for the OpenAI-compatible NineGate API gateway, frontier model auto-routing architecture, and Atlas agent orchestration.
Quickstart
NineGate provides a 100% OpenAI-compatible endpoint. You can use standard OpenAI SDKs or bare HTTP clients by simply pointing baseURL to NineGate.
curl -X POST https://ninegate.dritech.co.id/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ng_live_YOUR_API_KEY" \
-d '{
"model": "auto",
"messages": [
{"role": "system", "content": "You are a concise expert engineer."},
{"role": "user", "content": "Explain NineGate architecture in one paragraph."}
],
"temperature": 0.7
}'API Keys & Security
All requests to NineGate API endpoints require an Authorization header containing your API secret key formatted as a Bearer token.
- Key prefix: ng_live_ designates an active production API credential.
- Keys are hashed via SHA-256 before storage. Store credentials strictly in secure environment variables.
- The Atlas desktop application authenticates automatically via OAuth 2.1 Device Flow, eliminating the need to copy keys manually.
Core Endpoints Reference
Official HTTP routes provided by the NineGate Gateway:
/v1/chat/completionsCreates a model response for the given conversation history, with support for reasoning effort, tool calls, and streaming.
/v1/modelsLists all models and combo routes currently unlocked for your subscription plan.
/v1/accountRetrieves active subscription details, current tier, sliding window token balances, and account status.
/healthPublic lightweight health probe answering with gateway availability and version status without authentication.
Server-Sent Events (SSE) Streaming
Pass stream: true to receive tokens as they are generated over a standard Server-Sent Events connection with minimal first-byte latency.
from openai import OpenAI
client = OpenAI(
base_url="https://ninegate.dritech.co.id/v1",
api_key="ng_live_YOUR_API_KEY",
)
stream = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Tulis puisi tentang laut."}],
stream=True,
)
for chunk in stream:
token = chunk.choices[0].delta.content or ""
print(token, end="", flush=True)Models & Combo Architecture
NineGate provides an 'auto' route that orchestrates intelligent multi-provider fallback at the gateway layer:
| Model | Key Capability | Fallback Strategy |
|---|---|---|
| auto | Smart auto-route: Claude 3.5 Sonnet -> Gemini 1.5 Pro -> GPT-4o | Automatic failover on upstream stall |
| anthropic/claude-3-5-sonnet | Elite coding, agentic reasoning, refactoring | Direct route |
| google/gemini-1.5-pro | Massive context window analysis (up to 1M+ tokens) | Direct route |
| openai/gpt-4o | High speed multimodal reasoning | Direct route |
Quota Windows & Rate Limit Headers
NineGate manages usage via dual rolling sliding windows (5-hour and weekly) providing burst capacity while safeguarding subscription limits.
- x-ratelimit-remaining-tokens: 1450000 (Remaining token balance)
- x-ratelimit-limit-tokens-5h: 2000000 (5-hour burst window token ceiling)
- x-ratelimit-reset: 1762839600 (UNIX epoch timestamp of next reset)
HTTP Status Codes & Troubleshooting
Standard HTTP status codes returned by the gateway and how to handle them:
| Status | Reason | Remediation |
|---|---|---|
| 400 Bad Request | Malformed JSON or invalid schema | Check payload formatting |
| 401 Unauthorized | Invalid, missing, or revoked API key | Verify Authorization header key |
| 402 Payment Required | Token quota exhausted or plan expired | Upgrade plan or wait for reset window |
| 403 Forbidden | Model not unlocked in your plan | Use model 'auto' or upgrade tier |
| 429 Too Many Requests | Request rate ceiling reached | Apply exponential backoff |
| 500 Internal Error | Gateway service internal exception | Retry request after a short interval |
| 504 Gateway Timeout | Upstream provider did not respond | Handled automatically by model 'auto' |
Atlas Agent Integration
Atlas is the autonomous local AI agent running across your desktop, shell, and browser connected directly to NineGate:
# Pasang Atlas di Linux/macOS
curl -fsSL https://ninegate.dritech.co.id/api/install | bash
# Masuk dengan akun NineGate via browser
atlas login
# Menjalankan tugas otonom di direktori kerja
atlas run "Audit performa web dan buatkan laporan optimasi"
# Memeriksa status model aktif & kuota
atlas modelsAtlas automatically synchronizes credentials and quotas securely through OAuth Device Flow.
Extended conversations utilize strict prompt caching prefixes to maximize speed and minimize token costs.
Frequently Asked Questions
Can I use official OpenAI client libraries?
Yes. NineGate supports standard OpenAI Chat Completions request and response schemas, including streaming tokens and tool calls.
Is my prompt data stored or used for model training?
No. NineGate adheres to strict zero-retention policies for prompt and completion contents. Data is processed strictly in-memory and never used for training.
What happens if I exhaust my token quota before renewal?
You can upgrade to a higher tier with prorated billing credit or wait for your sliding window token pools to replenish.
