NezhaGateNezhaGate
API Documentation

NezhaGate API Developer Docs

An OpenAI-compatible API: one endpoint and one key for GPT, Claude, Gemini, DeepSeek and other chat models, plus image and video generation. Every example below runs as-is.

Quick Start

Just swap in the Base URL and API Key, and your existing OpenAI SDK works out of the box.

Base URL
https://nezhagate.com/v1
curl · Chat API: Chat Completions
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": "Write a short product intro for an 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.

More runnable examples (Python / Node / curl, including the async image and video flow): github.com/gaoorange/nezhagate-api-examples

Authentication

All API calls require a Bearer Token.

Header
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.

ModelCapabilityEndpointPrice
gpt-5.6-solFrontier reasoning, agentic coding, long-horizon tasks, structured output/chat/completions Input $1.2/1M · Output $6.0/1M API Docs →
gpt-5.6-lunaHigh-speed chat, agentic coding, high-volume low-latency, structured output/chat/completions Input $0.07/1M · Output $0.4/1M API Docs →
gpt-6-astraDeep reasoning, agentic coding, very long context, image input, structured output/chat/completions Input $3.0/1M · Output $15.0/1M API Docs →
gpt-6.1-solAgentic coding, complex coding, professional document and analysis work, reasoning, very long context, image input, structured output/chat/completions Input $0.6/1M · Output $3.0/1M API Docs →
gpt-6-solComplex coding, agentic workflows, reasoning, very long context, image input, structured output/chat/completions Input $0.6/1M · Output $3.0/1M API Docs →
gpt-6-lunaHigh-volume chat, low-latency agent steps, classification and extraction, very long context, structured output/chat/completions Input $0.07/1M · Output $0.4/1M API Docs →
gpt-image-2Text-to-image, image-to-image, covers, posters, illustrations/images/generations 1K $0.005 · 2K $0.025 · 4K $0.04 API Docs →
gpt-image-2.5-flareText-to-image, image-to-image, covers, posters, illustration, typography/images/generations 1K $0.005 · 2K $0.03 · 4K $0.05 API Docs →
gpt-image-2.5-sunburstText-to-image, image-to-image, covers, posters, illustration, typography/images/generations 1K $0.005 · 2K $0.03 · 4K $0.05 API Docs →
nano-banana-2Text-to-image, image-to-image, covers, posters, illustrations/images/generations 1K $0.015 · 2K $0.025 · 4K $0.04 API Docs →
nano-banana-proText-to-image, image-to-image, covers, posters, illustrations, infographics/images/generations 1K $0.02 · 2K $0.03 · 4K $0.05 API Docs →
nano-banana-2.1Text-to-image, image editing, multi-image composition, posters and infographics, product shots, wide banners/images/generations 1K $0.015 · 2K $0.025 · 4K $0.04 API Docs →
grok-imagine-imageText-to-image, image editing, posters, product shots, social visuals, Chinese and English lettering/images/generations 1K $0.005 · 2K $0.005 · 4K $0.0 API Docs →
grok-imagine-image-qualityCovers, posters, product shots, illustration, text-to-image and image editing/images/generations 1K $0.01 · 2K $0.01 · 4K $0.0 API Docs →
claude-sonnet-4-6Chat, code, reasoning, long context/chat/completions Input $1.5/1M · Output $7.5/1M API Docs →
claude-opus-5Deep reasoning, code, agents, long context, image understanding/chat/completions Input $4.0/1M · Output $20.0/1M API Docs →
claude-fable-5Chinese writing, narrative creation, long-form generation, chat, code, image understanding/chat/completions Input $8.0/1M · Output $40.0/1M API Docs →
claude-opus-5-5Complex reasoning, long-horizon agentic coding, code engineering, tool calling, image and PDF understanding/chat/completions Input $2.5/1M · Output $12.5/1M API Docs →
claude-sonnet-5-5Everyday coding and agents, long context, tool calling, image and PDF understanding, production traffic at scale/chat/completions Input $1.5/1M · Output $7.5/1M API Docs →
gemini-4-argonBeta · reasoning · long context/chat/completions Input $0.5/1M · Output $3.0/1M API Docs →
gemini-3.1-proChat, reasoning, very long context, multimodal/chat/completions Input $0.5/1M · Output $3.0/1M API Docs →
gemini-3.8-flashChat, reasoning, adaptive thinking, image input, very long context/chat/completions Input $0.6/1M · Output $3.6/1M API Docs →
deepseek-v4.1-flashChat, reasoning, coding, tool calling, switchable thinking mode/chat/completions Input $0.075/1M · Output $0.3/1M API Docs →
deepseek-v4-flash-0731Chat, reasoning, coding, tool calling, switchable thinking mode, pinned version/chat/completions Input $0.13/1M · Output $0.51/1M API Docs →
glm-5.3Chat, coding, agentic workflows, reasoning, Chinese and English writing, tool calling/chat/completions Input $1.12/1M · Output $3.52/1M API Docs →
qwen3.8-maxReasoning, coding, agents and tool calling, Chinese and English writing, image understanding/chat/completions Input $1.4/1M · Output $4.2/1M API Docs →
qwen3.8-flashHigh-volume chat, classification and extraction, summarising and rewriting, image understanding and OCR, tool calling/chat/completions Input $0.1/1M · Output $0.33/1M API Docs →
grok-4.7Complex reasoning, coding, long-document analysis, tool calling, structured output, image understanding/chat/completions Input $0.3/1M · Output $0.9/1M API Docs →
veo-3.1Short clips, product motion, first/last-frame transitions, commercial footage/videos/generations $0.2 /clip+ API Docs →
gemini-omni-flashMulti-shot clips, storyboard narratives, first/last-frame transitions/videos/generations $0.05 /s API Docs →
kling-4.0Character action, product shorts, motion taken from a reference video/videos/generations $0.09 /s API Docs →
seedance-2.5-tokenText, image, video and audio references/videos/generations $7.50–13.75 /1M video tokens API Docs →
seedance-2.5-token-draftText, image, video and audio references/videos/generations $7.50–12.50 /1M video tokens API Docs →
seedance-2.5Long-take short films, multi-reference input, commercial footage/videos/generations $0.158 /s API Docs →
seedance-2.0Short clips, commercial assets/videos/generations $0.15 /s API Docs →
seedance-2.0-fastBulk assets, quick concept checks/videos/generations $0.075 /s API Docs →
seedance-2.0-clipShort clips featuring real people, product videos, batch production/videos/generations $1.0 /clip+ API Docs →
seedance-2.5-30sLong-take storytelling, long-form product videos/videos/generations $2.0 /clip+ API Docs →
wan3.0-videoLong-take storytelling, multi-asset composition, video rewriting/videos/generations $0.065 /s API Docs →
wan3.0-video-primeDeadline footage, batch test shoots/videos/generations $0.112 /s API Docs →
minimax-h3HD footage, short clips with sound/videos/generations $0.036 /s API Docs →
grok-imagine-video-1.5Bulk short videos, quick concept checks/videos/generations $0.3 /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 URLhttps://nezhagate.com/v1
API keythe key you create in the console (Console → API Keys → Copy)
Model namegpt-5.6-sol gpt-5.6-luna gpt-6-astra gpt-6.1-sol gpt-6-sol gpt-6-luna gpt-image-2 gpt-image-2.5-flare gpt-image-2.5-sunburst nano-banana-2 nano-banana-pro nano-banana-2.1 grok-imagine-image grok-imagine-image-quality claude-sonnet-4-6 claude-opus-5 claude-fable-5 claude-opus-5-5 claude-sonnet-5-5 gemini-4-argon gemini-3.1-pro gemini-3.8-flash deepseek-v4.1-flash deepseek-v4-flash-0731 glm-5.3 qwen3.8-max qwen3.8-flash grok-4.7 veo-3.1 gemini-omni-flash kling-4.0 seedance-2.5-token seedance-2.5-token-draft seedance-2.5 seedance-2.0 seedance-2.0-fast seedance-2.0-clip seedance-2.5-30s wan3.0-video wan3.0-video-prime minimax-h3 grok-imagine-video-1.5

Verified with ChatBox, Cherry Studio, NextChat, LobeChat, Immersive Translate, Open WebUI, etc.

Step-by-step client guides: SillyTavern · Cherry Studio · Cline

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.

Claude Code · env
export ANTHROPIC_BASE_URL=https://nezhagate.com/anthropic
export ANTHROPIC_API_KEY=YOUR_API_KEY
# claude-sonnet-4-6 / claude-opus-5 / claude-fable-5 / claude-opus-5-5 / claude-sonnet-5-5
curl · /anthropic/v1/messages
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-opus-5-5, claude-sonnet-5-5, claude-opus-5, claude-sonnet-5, claude-fable-5, 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-12 min per clip. Two billing modes: Veo 3.1 is billed per clip; Seedance 2.x and MiniMax H3 are billed per second (rate x duration). Both hold exactly what they settle and refund in full on failure. Set the aspect ratio via size (16:9 landscape is the default); for image-to-video pass a first-frame reference in image.

curl · submit
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": "fast", "resolution": "1080p", "size": "16:9"}'
curl · poll
curl https://nezhagate.com/v1/videos/jobs/img_3f9a...c2 -H 'Authorization: Bearer YOUR_API_KEY'

Video models: veo-3.1 gemini-omni-flash kling-4.0 seedance-2.5-token seedance-2.5-token-draft seedance-2.5 seedance-2.0 seedance-2.0-fast seedance-2.0-clip seedance-2.5-30s wan3.0-video wan3.0-video-prime minimax-h3 grok-imagine-video-1.5

Webhooks: get notified when a job finishes

Video and image generation are asynchronous: you submit, get a job ID, and the result arrives a little later. Instead of polling, let us push the result to your server when the job ends, and warn you when your balance runs low.

Rather not poll? Add callback_url when you submit and we push the result to your server when the job ends, or set a default endpoint in the console. Webhook docs →

Agent Skills: make a video in one sentence from your coding agent

Install the NezhaGate skill in Claude Code, Codex, Cursor or another skill-aware agent, then just ask: "turn this image into an 8-second video with seedance-2.5 and save it to ./out". The agent picks the model, uploads your files, waits for the render and saves the result. Available now: the Seedance 2.5 / 2.0 video skill.

Install
npx skills add https://nezhagate.com
API key
export NEZHAGATE_API_KEY=YOUR_API_KEY

github.com/gaoorange/nezhagate-skills · Demo clip (8 s, one request)

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.

AI Integration Prompt
Integrate NezhaGate through its OpenAI-compatible API.
Base URL: https://nezhagate.com/v1
API Key: read it from the environment variable NEZHAGATE_API_KEY.
Claude models can also use the native Anthropic protocol (for Claude Code / the Anthropic SDK): ANTHROPIC_BASE_URL=https://nezhagate.com/anthropic, headers x-api-key=API Key and anthropic-version: 2023-06-01, POST /anthropic/v1/messages (max_tokens is required), models claude-sonnet-4-6 / claude-opus-5 / claude-fable-5 / claude-opus-5-5 / claude-sonnet-5-5.
Chat models (/chat/completions): gpt-5.6-sol / gpt-5.6-luna / gpt-6-astra / gpt-6.1-sol / gpt-6-sol / gpt-6-luna / claude-sonnet-4-6 / claude-opus-5 / claude-fable-5 / claude-opus-5-5 / claude-sonnet-5-5 / gemini-4-argon / gemini-3.1-pro / gemini-3.8-flash / deepseek-v4.1-flash / deepseek-v4-flash-0731 / glm-5.3 / qwen3.8-max / qwen3.8-flash / grok-4.7
Image models (text-to-image /images/generations; image-to-image /images/edits or add an image parameter): gpt-image-2 / gpt-image-2.5-flare / gpt-image-2.5-sunburst / nano-banana-2 / nano-banana-pro / nano-banana-2.1 / grok-imagine-image / grok-imagine-image-quality
Video models (/videos/generations, async jobs; add reference images for image-to-video; how each model uses them is in its own doc): veo-3.1 / gemini-omni-flash / kling-4.0 / seedance-2.5-token / seedance-2.5-token-draft / seedance-2.5 / seedance-2.0 / seedance-2.0-fast / seedance-2.0-clip / seedance-2.5-30s / wan3.0-video / wan3.0-video-prime / minimax-h3 / grok-imagine-video-1.5
Auth: Authorization: Bearer YOUR_API_KEY
Requirements (chat): return choices[0].message.content; on 401 check the key, 402 means insufficient balance, 429/5xx can be retried.
Requirements (images, async): POST /images/generations or /images/edits returns HTTP 202 with a job id right away ({"id":"img_...","object":"image.generation.job","status":"queued"}); then poll GET /v1/images/jobs/{id} until status=succeeded and read data[0].url (an img.nezhagate.com link kept for 15 days; download it or copy it to your own storage). Do not read data right after submitting.
Requirements (video, async): POST /videos/generations returns HTTP 202 with a job id (object=video.generation.job); then poll GET /v1/videos/jobs/{id} until status=succeeded and read data[0].url (a re-hosted mp4 link kept for 15 days). Render time varies by model (from a minute or two to over an hour); failed jobs are refunded in full.

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 · /v1/usage
curl https://nezhagate.com/v1/usage -H "Authorization: Bearer YOUR_API_KEY"
curl · /v1/dashboard/billing/credit_grants
curl https://nezhagate.com/v1/dashboard/billing/credit_grants -H "Authorization: Bearer YOUR_API_KEY"

Error Codes

Errors from the /v1 endpoints share the shape below (the /anthropic endpoints use Anthropic's own format). code is a stable, machine-readable identifier: branch on code, never on the message text.

error envelope
{
  "error": {
    "message": "human readable",
    "type": "invalid_request_error | authentication_error | permission_error | insufficient_quota | rate_limit_error | server_error",
    "code": "stable_snake_case",
    "param": "field_name_or_null"
  }
}
HTTPMeaning
400A bad parameter or an unknown model (such as model_not_found); error.param names the field.
401No key, or the key is invalid or disabled (missing_api_key, invalid_api_key).
402Not enough balance, or the key has reached its budget (insufficient_quota).
403The model is not on this key's model allowlist, or the request comes from outside the key's IP allowlist (permission_denied).
404The path does not exist; or the job id is unknown, past its 3-day record, or was submitted by another account (job_not_found).
429Over the per-minute limit set on this key or a free model's daily quota, or every line for the model is busy (rate_limit_exceeded). Wait the seconds in Retry-After when it is there, otherwise a few seconds, then retry.
502The upstream failed or timed out and switching lines did not help; code says why, e.g. upstream_timeout or upstream_unavailable. Not billed; safe to retry.
503The model is under maintenance (model_maintenance), or something failed on our side for a moment (service_unavailable). Not billed; retry later.

Full list of error codes →

max_tokens on thinking models — Gemini 3.x Flash (3-flash-preview / 3.6 / 3.7 / 3.8, every tier) spend the budget on hidden reasoning before writing the visible answer, so a small budget is consumed before the answer starts: measured, max_tokens=16 fails outright and 32 / 64 return a plausible-looking wrong value with finish_reason=length. The gateway raises the output budget for those models to at least 512 (you are billed only for tokens actually used), but send >=512 yourself; treat any finish_reason=length as possibly truncated and retry with a larger max_tokens.

Common questions on access, billing, models and safety. NezhaGate FAQ →