NineGate v1 Official Documentation

API Documentation & Atlas Guide

Complete reference for the OpenAI-compatible NineGate API gateway, frontier model auto-routing architecture, and Atlas agent orchestration.

Getting Started

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
  }'
Authentication

API Keys & Security

All requests to NineGate API endpoints require an Authorization header containing your API secret key formatted as a Bearer token.

Authorization: Bearer ng_live_xxxxxxxxxxxxxxxxxxxxxxxx
  • 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.
API Endpoints

Core Endpoints Reference

Official HTTP routes provided by the NineGate Gateway:

POST/v1/chat/completions

Creates a model response for the given conversation history, with support for reasoning effort, tool calls, and streaming.

{ model: string, messages: Message[], stream?: boolean, temperature?: number, reasoning_effort?: 'low'|'medium'|'high' }
GET/v1/models

Lists all models and combo routes currently unlocked for your subscription plan.

GET/v1/account

Retrieves active subscription details, current tier, sliding window token balances, and account status.

GET/health

Public lightweight health probe answering with gateway availability and version status without authentication.

Real-time Streaming

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.

Python Streaming Example
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)
Model Catalog

Models & Combo Architecture

NineGate provides an 'auto' route that orchestrates intelligent multi-provider fallback at the gateway layer:

ModelKey CapabilityFallback Strategy
autoSmart auto-route: Claude 3.5 Sonnet -> Gemini 1.5 Pro -> GPT-4oAutomatic failover on upstream stall
anthropic/claude-3-5-sonnetElite coding, agentic reasoning, refactoringDirect route
google/gemini-1.5-proMassive context window analysis (up to 1M+ tokens)Direct route
openai/gpt-4oHigh speed multimodal reasoningDirect route
Quotas & Limits

Quota Windows & Rate Limit Headers

NineGate manages usage via dual rolling sliding windows (5-hour and weekly) providing burst capacity while safeguarding subscription limits.

Response Headers for Quota Monitoring:
  • 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)
Error Handling

HTTP Status Codes & Troubleshooting

Standard HTTP status codes returned by the gateway and how to handle them:

StatusReasonRemediation
400 Bad RequestMalformed JSON or invalid schemaCheck payload formatting
401 UnauthorizedInvalid, missing, or revoked API keyVerify Authorization header key
402 Payment RequiredToken quota exhausted or plan expiredUpgrade plan or wait for reset window
403 ForbiddenModel not unlocked in your planUse model 'auto' or upgrade tier
429 Too Many RequestsRequest rate ceiling reachedApply exponential backoff
500 Internal ErrorGateway service internal exceptionRetry request after a short interval
504 Gateway TimeoutUpstream provider did not respondHandled automatically by model 'auto'
Application & CLI

Atlas Agent Integration

Atlas is the autonomous local AI agent running across your desktop, shell, and browser connected directly to NineGate:

Basic Atlas CLI Commands
# 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 models
1. Zero Manual API Setup

Atlas automatically synchronizes credentials and quotas securely through OAuth Device Flow.

2. Sacred Prompt Caching

Extended conversations utilize strict prompt caching prefixes to maximize speed and minimize token costs.

FAQ

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.