Fast model access
A Rust gateway with streaming support and measured proxy performance. Connect applications and coding tools through compatible API endpoints.
The Token Platform for developers and teams. Access models with performance and reliability, and keep token usage and spending under control.
Compare gatewaysBrowse modelsWhy Niu?
Inspect every workspace operation, upstream route-pool attempt, phase latency, and settled customer tariff.
| Model & time | Status | Charge & latency |
|---|---|---|
A claude-sonnet-414:22:08 · Anthropic | Completed | $0.01801,180 ms |
OR claude-sonnet-414:22:07 · OpenRouter | Failed · HTTP 401 | Not charged3.2 ms |
DS deepseek-r114:19:41 · OpenRouter | Uncertain | Unresolved4,820 ms |
A Rust gateway with streaming support and measured proxy performance. Connect applications and coding tools through compatible API endpoints.
Model routing, bounded failover and attempt-level logs help you understand failures. Unresolved usage stays explicit.
Review model prices, token usage and request charges. Set workspace and API-key budgets before usage grows.
Use APIs in your applications, compare models in Chat, and revisit saved conversations and supported video results.
10× PERFORMANCE · MEASURED BENCHMARKS
Why Rust? Because your gateway should never be the bottleneck. Measured with ai-gateway-bench on Apple M4 with PostgreSQL 17.11, Niu sustains 3,239 RPS with full database accounting and 18.2 MB idle RAM.
10.7x LiteLLM Proxy and 3.7x New API peak at c = 64 (/v1/chat/completions), with 31.54 ms p99 tail latency.
9,436 tokens/s at c = 16 with 1.34 ms median inter-token latency (ITL) and 100% SSE chunk preservation.
7.4x lower peak RAM and 10.7x lower proxy compute cost ($0.014 / 1M requests) while persisting ACID PostgreSQL records.
Isolates gateway routing, workspace key verification, protocol handling, and PostgreSQL accounting overhead against a deterministic 0ms mock upstream (36,649 RPS direct baseline).
Rust · Axum · Tokio
Go · Gin · GORM (45fbb14)
Python · FastAPI (v1.104.0)
Niu records pre-dispatch operations and attempts in a single SQL CTE and coalesces up to 64 post-dispatch completions per batch transaction, keeping c = 64 p99 latency at 31.54 ms while LiteLLM Proxy saturates its Python event loop at ~302 RPS.
Measures completed SSE streams/sec, delivered tokens/sec, Time-To-First-Token (TTFT), Inter-Token Latency (ITL), and whether the gateway preserves all 43 SSE frames per response.
Rust · Tokio zero-copy SSE
Go Gin SSE relay (45fbb14)
Python async SSE (v1.104.0)
Because LiteLLM Proxy instantiates and serializes Python/Pydantic chunk objects on every SSE token event, it adds 194 µs per chunk at c = 1 and plateaus at 83.0 streams/s at c = 16. Niu forwards SSE frames directly through Tokio byte streams while extracting terminal usage.
Simulates 8 and 16 concurrent coding agents executing 30 sequential turns each with conversation context growing from 1.5 KB on turn 1 to 25 KB on turn 30.
Native /v1/messages & /v1/chat
Go channel relay (45fbb14)
Python FastAPI (v1.104.0)
As growing conversation histories reach 25 KB per turn across 16 simultaneous agents, JSON re-parsing and event-loop contention double LiteLLM Proxy's completion time (3.06s to 5.80s). Niu completes all 480 turns in 1.69s with a flat 54 ms median turn time.
Measures idle and peak resident memory (RSS) under 64-worker load and calculates gateway compute cost per 1M proxied requests at 60% target CPU utilization.
Single static Rust binary
Go binary + GORM (45fbb14)
Python 3.12 + SDKs (v1.104.0)
Importing Python provider SDKs and tokenizers consumes 158–195 MB per LiteLLM worker before serving traffic. Niu's native Rust binary starts in 18.2 MB and grows by only 8.2 MB under 64-worker saturation.
Fairness note: Niu v0.2.4 ran with full ACID PostgreSQL pre-dispatch admission & batched completion; New API (45fbb14) ran with MEMORY_CACHE_ENABLED=true; LiteLLM Proxy (v1.104.0) ran in stateless master_key mode with DB logs disabled. Always qualify your own deployment and workload.
YOUR TOKEN WORKSPACE
Connect your applications, try models in Chat, and manage keys, budgets and request history together.
Use one model entry point across configured routes. Inspect each attempt and understand when a fallback occurred.
Models & routingInspect request status, token counts, timing and charges without stitching together separate dashboards.
Request evidenceReview the price of a model and the charge for each request. Keep missing or unresolved billing evidence visible.
Usage & spendingSet scoped API keys and spending caps for your applications and team, with in-flight budget reservations.
Access & limitsNative OpenAI (/v1/chat/completions, /v1/responses) and Anthropic (/v1/messages) compatibility. Change one Base URL to connect Claude Code, Codex, or your app.
API & SDKTry models in Chat and manage supported video jobs. Saved sessions and authorized results stay available across visits.
GenerationsDROP-IN COMPATIBILITY
Point any OpenAI-compatible client, Claude Code, or Codex at your Niu gateway using a scoped workspace API key.
Browse available models, check capabilities and prices, and choose the model that fits your workload.
Create a workspace API key, limit its model access, and set a spending cap for your application.
Clients stream responses with zero code changes while Niu handles automatic failover, token metering, and real-time billing.
curl http://localhost:2555/v1/chat/completions \
-H "Authorization: Bearer $NIU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"messages": [{"role": "user", "content": "Check Q3 p99."}],
"stream": true
}'FULL-STACK OPEN SOURCE · SELF-HOSTED
The gateway, dashboard, model catalog, and docs are MIT-licensed with zero black-box dependencies or license servers—your data stays 100% yours.
FROM THE NIU BLOG
Model access, token usage and reliable API integration in practice.
All articlesPerformance, reliability and economy for people using model APIs. Access models, manage token spending and understand every request.
Read articleHosted model access or a gateway you operate? Compare operating responsibilities, workspace budgets and request evidence before choosing.
Read articleFREQUENTLY ASKED QUESTIONS
What developers and teams need to know before connecting their applications.
Niu is a token management platform for developers and teams using model APIs. Access models, manage workspace keys and budgets, and inspect usage and request charges from one workspace.
Browse modelsCheck the listed model price, review actual token usage and charges, and set workspace and key-level budgets. Prices and availability depend on the configured offers; Niu does not promise every model is cheaper.
Usage & budgetsNo mystery charges and no fake $0 bills. Niu records pre-dispatch state in PostgreSQL and never blindly replays a request that may have already run upstream. If a stream drops without usage evidence, the call is explicitly flagged as unresolved for review.
Request evidence contractYes. The Rust gateway, admin console, customer workspace dashboard, model catalog, and docs are all MIT-licensed and run together against a single PostgreSQL database—with zero license servers or private dependencies.
Single-container deploymentUse a scoped workspace API key with the documented OpenAI-compatible and Anthropic-compatible endpoints. Check the model capabilities and supported protocol before switching your application.
API quickstartNiu includes model access, workspace API keys and budgets, request logs, and saved Chat and supported Video workflows. Availability depends on configured models and permissions. Consult the release matrix for qualification limits.
Release acceptance matrixPERFORMANCE · RELIABILITY · ECONOMY
Browse models, create a workspace API key and start calling. You can also self-host the open-source stack.