Niu Documentation
Route every model API through one high-throughput gateway, orchestrate smart Model Pools, and run multi-tenant billing out of the box.
Whether you are connecting an app in five minutes, equipping coding agents via MCP, or self-hosting a commercial AI gateway for your customers, start from a verified guide below.
Choose your path
Jump straight to the workflow matching what you are building or operating today.
5-Minute Quickstart
Get a workspace API key, discover authorized models, and send your first chat or streaming request.
Read guideModel Pools & Routing
Combine multiple Providers under one custom model name with context rules, failover, and strategy audit.
Read guideWorkspaces, Pricing & Credits
Onboard customers, publish customer tariffs, configure Stripe/WeChat Pay or grants, and enforce budgets.
Read guideSingle-Container Deployment
Run the Rust gateway, web console, and documentation together on your own infrastructure with PostgreSQL.
Read guideSend a real request in seconds
Call any authorized model route or published Model Pool using your workspace API key.
curl https://niu.io/v1/chat/completions \
-H "Authorization: Bearer $NIU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-coder",
"messages": [
{ "role": "user", "content": "Explain Rust zero-copy SSE streaming in two sentences." }
]
}'Explore by capability
End-to-end guides covering application integration, commercial operations, and production reliability.
Connect & Build
Integrate models, media, and coding agents
API tutorial & live console
Test live workspace requests right inside the browser and inspect headers.
TypeScript SDK tutorial
Typed chat, streaming SSE, async video polling, and error handling.
Coding agents (MCP)
Expose catalog discovery, multi-model calls, and billing lookup to MCP clients.
Generations & Video jobs
Saved multimodal chat threads, async video generation, and workspace materials.
Commercialize & Govern
Run Niu as an internal hub or commercial API business
Providers & supply readiness
Manage encrypted Provider credentials, route capabilities, and approved offers.
Customer pricing & tariffs
Publish workspace selling prices while keeping upstream purchase costs private.
Guardrails & request capacity
Configure input/output content policies, RPM/TPM windows, and concurrency caps.
Customers, roles & payments
Provision organizations, workspace roles, credit grants, and payment gateways.
Observe & Operate
Production telemetry, accounting evidence, and benchmarks
Request logs & payload retention
Inspect per-attempt status, TTFT/latency, token usage, and 24h payload controls.
Usage & billing settlement
Understand pre-dispatch holds, terminal stream evidence, and recovery workers.
Security & boundary model
AES-256-GCM secret storage, commercial data isolation, and session security.
3,239 RPS gateway benchmarks
Reproducible throughput, tail latency, SSE streaming, and 18 MB RSS measurements.
Contracts & Reference Specifications
Generated directly from checked-in OpenAPI contracts and TypeScript SDK declarations.
REST API Specification
460+ generated operations covering inference, media, Model Pools, billing, and administration.
TypeScript SDK Reference
Compiler-emitted classes, methods, request options, and inferred TypeScript return types.
Compare AI Gateways
Side-by-side comparison of Niu, OpenRouter, New API, and LiteLLM across deployment and governance.
按角色快速上手
根据您当前的使用场景,直接进入对应的核心工作流。
几秒内发起首个真实请求
使用工作空间 API 密钥,零改造调用任意已授权模型路由或自定义模型池。
curl https://niu.io/v1/chat/completions \
-H "Authorization: Bearer $NIU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-coder",
"messages": [
{ "role": "user", "content": "Explain Rust zero-copy SSE streaming in two sentences." }
]
}'全栈能力指南目录
覆盖应用开发集成、多租户商业化运营与生产级高可用运维的完整文档体系。
接入与构建
模型推理、多媒体与智能体集成
商业化与平台治理
内部中台治理与对外商业售卖
接口契约与技术参考
由代码仓库中的 OpenAPI 契约与 TypeScript SDK 源码自动编译生成,确保与线上实现严格一致。