An OpenAI-compatible AI Gateway — one endpoint for the full catalogue: GPT-5.5, the Gemini chat family and gpt-image generation. Readable by humans, and one-click copyable for AI coding assistants.
Quick Start
Just swap in the Base URL and API Key, and your existing OpenAI SDK works out of the box.
https://nezhagate.com/v1
curl https://nezhagate.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "gpt-5.5", "messages": [{"role": "user", "content": "写一段 AI API 产品介绍"}], "stream": false}'
Full request parameters, examples and async usage for each model live in that model's own doc — open it from the Models & pricing table below.
Authentication
All API calls require a Bearer Token.
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
Models & Pricing
Full request parameters, examples and async usage for each model live in that model's own doc — open it from the Models & pricing table below.
| Model | Capability | Endpoint | Price | |
|---|---|---|---|---|
| gpt-5.6-sol | 前沿推理、Agentic 编程、长链路任务、结构化输出 | /chat/completions | Input $2.0/1M · Output $12.0/1M | API Docs → |
| gpt-5.6-terra | 日常对话、Agentic 编程、推理、结构化输出 | /chat/completions | Input $1.2/1M · Output $7.0/1M | API Docs → |
| gpt-5.6-luna | 高速对话、Agentic 编程、大批量低延迟、结构化输出 | /chat/completions | Input $0.8/1M · Output $4.8/1M | API Docs → |
| gpt-5.5 | 对话、推理、Agent、结构化输出 | /chat/completions | Input $0.7/1M · Output $4.2/1M | API Docs → |
| gpt-image-2 | 文生图、图生图、封面、海报、插画 | /images/generations | 1K $0.015 · 2K $0.025 · 4K $0.04 | API Docs → |
| nano-banana-2 | 文生图、图生图、封面、海报、插画 | /images/generations | 1K $0.025 · 2K $0.0375 · 4K $0.0625 | API Docs → |
| nano-banana-pro | 文生图、图生图、封面、海报、插画、信息图 | /images/generations | 1K $0.04 · 2K $0.06 · 4K $0.1 | API Docs → |
| claude-sonnet-4-6 | 对话、代码、推理、长上下文 | /chat/completions | Input $1.5/1M · Output $7.5/1M | API Docs → |
| gemini-3.1-pro | 对话、推理、超长上下文、多模态 | /chat/completions | Input $0.5/1M · Output $3.0/1M | API Docs → |
| gemini-3.6-flash | 对话、推理、思考、图片输入、超长上下文 | /chat/completions | Input $0.6/1M · Output $3.6/1M | API Docs → |
| gemini-3.6-flash-high | 深度推理、复杂任务、思考、图片输入、超长上下文 | /chat/completions | Input $0.6/1M · Output $3.6/1M | API Docs → |
| gemini-3.6-flash-low | 高速对话、大批量、低延迟、图片输入 | /chat/completions | Input $0.6/1M · Output $3.6/1M | API Docs → |
| gemini-3.6-flash-tiered | 自适应思考、对话、推理、图片输入 | /chat/completions | Input $0.6/1M · Output $3.6/1M | API Docs → |
| gemini-3-flash-preview | 对话、推理、高并发、低延迟 | /chat/completions | Input $0.3/1M · Output $1.2/1M | API Docs → |
| gemini-3.5-flash | 对话、推理、高并发、低延迟、思考 | /chat/completions | Input $0.45/1M · Output $2.7/1M | API Docs → |
| gemini-2.5-flash | 对话、高并发、低延迟、多模态 | /chat/completions | Input $0.3/1M · Output $1.2/1M | API Docs → |
| veo-3.1 | 文生视频、图生视频、短片、商业成片 | /videos/generations | $0.075 /clip | API Docs → |
Use it in an app (no code)
In any app that speaks the OpenAI API, fill in these three fields — no programming needed:
| API base URL | https://nezhagate.com/v1 |
| API key | the key you create in the console (Console → API Keys → Copy) |
| Model name | gpt-5.6-sol gpt-5.6-terra gpt-5.6-luna gpt-5.5 gpt-image-2 nano-banana-2 nano-banana-pro claude-sonnet-4-6 gemini-3.1-pro gemini-3.6-flash gemini-3.6-flash-high gemini-3.6-flash-low gemini-3.6-flash-tiered gemini-3-flash-preview gemini-3.5-flash gemini-2.5-flash veo-3.1 |
Verified with ChatBox, Cherry Studio, NextChat, LobeChat, Immersive Translate, Open WebUI, etc.
Native Anthropic API (Claude Code)
Beyond the OpenAI-compatible route, Claude models also expose the native Anthropic Messages API. Point Claude Code (or any Anthropic SDK) at the base URL below and use your gateway key as x-api-key — thinking, tool use and prompt caching are all preserved natively.
export ANTHROPIC_BASE_URL=https://nezhagate.com/anthropic export ANTHROPIC_API_KEY=YOUR_API_KEY # claude-opus-4-8 / claude-sonnet-4-6 / claude-haiku-4-5
curl https://nezhagate.com/anthropic/v1/messages -H "x-api-key: YOUR_API_KEY" -H "anthropic-version: 2023-06-01" -H "Content-Type: application/json" -d '{"model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}]}'
Models: claude-sonnet-4-6. Billed exactly like /v1, per token.
Prompt-cache billing: cache hits (cache read) are billed at 1/10 (0.1×) of the input rate, cache writes at 1.25× (per-model rates on the pricing page). A hit needs a stable, long-enough prefix (Claude Opus ≥ 4096 tokens, Sonnet ≥ 2048) repeated within a short window — Claude Code with a large CLAUDE.md / system prompt over a real codebase hits every turn, cutting input cost to ~1/10. Short Playground chats are too small to cache.
Video Generation (async)
Text-to-video / image-to-video are async jobs: the call returns HTTP 202 + a job id immediately ({"id":"img_...","object":"video.generation.job","status":"queued"}); poll GET /v1/videos/jobs/{id} until status=succeeded, result in data[0].url (a re-hosted mp4). ~1-2 min per clip, billed per clip, fully refunded on failure. Set orientation via size (16:9 landscape default, or 9:16 portrait); for image-to-video pass a first-frame reference in image.
curl https://nezhagate.com/v1/videos/generations -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{"model": "veo-3.1", "prompt": "a cat surfing at sunset", "tier": "quality", "resolution": "1080p", "size": "16:9", "duration": "8s"}'curl https://nezhagate.com/v1/videos/jobs/img_3f9a...c2 -H 'Authorization: Bearer YOUR_API_KEY'
Video models: veo-3.1
Integration Notes to Copy for AI
Send the whole block below to Codex / Claude Code / Cursor and it will know how to integrate. You can also use “Copy Page” in the top right to copy the entire doc.
请使用 OpenAI-compatible API 接入 NezhaAPI。
Base URL: https://nezhagate.com/v1
API Key: 从环境变量 NEZHAAPI_KEY 读取。
Claude 模型可选原生 Anthropic 口径(适合 Claude Code / Anthropic SDK 直连):ANTHROPIC_BASE_URL=https://nezhagate.com/anthropic,请求头 x-api-key=API Key + anthropic-version: 2023-06-01,POST /anthropic/v1/messages(必填 max_tokens),模型 claude-opus-4-8 / claude-sonnet-4-6 / claude-haiku-4-5。
对话模型(/chat/completions):gpt-5.6-sol / gpt-5.6-terra / gpt-5.6-luna / gpt-5.5 / claude-sonnet-4-6 / gemini-3.1-pro / gemini-3.6-flash / gemini-3.6-flash-high / gemini-3.6-flash-low / gemini-3.6-flash-tiered / gemini-3-flash-preview / gemini-3.5-flash / gemini-2.5-flash
生图模型(文生图 /images/generations,图生图 /images/edits 或加 image 参数):gpt-image-2 / nano-banana-2 / nano-banana-pro
生视频模型(文生视频 /videos/generations,异步任务;图生视频加 image 参数传首帧):veo-3.1
认证:Authorization: Bearer YOUR_API_KEY
要求(对话):返回 choices[0].message.content;401 检查 Key,402 余额不足,429/5xx 可重试。
要求(图片,异步任务):提交 /images/generations 或 /images/edits 立刻返回 HTTP 202 与任务号({"id":"img_...","object":"image.generation.job","status":"queued"});随后轮询 GET /v1/images/jobs/{id} 直到 status=succeeded,再读取 data[0].url(img.nezhagate.com 稳定直链)。不要在提交后直接读取 data。
要求(视频,异步任务):提交 /videos/generations 立刻返回 HTTP 202 与任务号(object=video.generation.job);随后轮询 GET /v1/videos/jobs/{id} 直到 status=succeeded,再读取 data[0].url(重托管 mp4 稳定直链)。单条约 1-2 分钟,失败全额退。
Check balance & usage
Use any API key to read the account remaining balance and spend — no dashboard login needed. Simplest: GET /v1/usage. Also OpenAI-compatible: /v1/dashboard/billing/credit_grants (balance = total_available).
curl https://nezhagate.com/v1/usage -H "Authorization: Bearer YOUR_API_KEY"
curl https://nezhagate.com/v1/dashboard/billing/credit_grants -H "Authorization: Bearer YOUR_API_KEY"
Error Codes
| Status Code | Meaning | How to Handle |
|---|---|---|
| 401 | API Key missing or invalid | Check the Authorization header |
| 402 | Insufficient balance or Key over quota | Contact the admin to top up |
| 400 | Unsupported model or parameter | Use only gpt-5.5 / gpt-image-2 |
| 429 | Upstream rate limit | Retry later |
| 502 | All upstream routes failed | Wait for recovery or contact the admin |