Docs
Waytocc Docs
Waytocc is one gateway for three things — chat (Claude / GPT / Gemini), AI agents (Claude Code / Codex) and image generation (gpt-image-2). The three are independent and each needs its own key. Pick what you need:
Overview
Chat: Claude · GPT · Gemini
Anthropic, OpenAI and Gemini protocols natively supported, real upstreams, streaming.
AI agents
Point Claude Code or Codex at us by changing one base URL — long tasks, real code.
Images: gpt-image-2
Text to image and image to image, OpenAI-compatible, Chinese prompts supported.
Official protocols
Keep each vendor's official SDK; change the base URL and nothing else.
Residential IP egress
Upstream traffic exits through overseas residential IPs — stable, low risk-control.
Pay as you go
Chat by token, images per image. Top up at ¥1 = $1; balance and usage update live.
Get a key
- 1. Open waytocc.com and register with your email.
- 2. Go to Wallet and top up any plan.
(Got an invite code? Enter it at top-up for a first-time bonus.) - 3. Go to API Keys and click New key. The key is shown once — copy it immediately.
Replace YOUR_API_KEY in every example below with your key (it looks like sk-...).
Claude chat (Messages API)
Waytocc serves real Claude, fully compatible with Anthropic's POST /v1/messages. Authenticate with x-api-key (or Authorization: Bearer) and set the model to claude-opus-5.
curl https://api.waytocc.com/v1/messages \
-H "x-api-key: YOUR_CLAUDE_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-opus-5","max_tokens":1024,"stream":true,"messages":[{"role":"user","content":"Introduce yourself in one sentence"}]}'The response matches Anthropic exactly; text is at content[0].text. Use stream:true — a long non-streamed answer can hit a 524 at the edge after ~100s. Billed per token (input + output); see Usage history.
GPT chat (OpenAI-compatible)
The same gateway serves OpenAI-compatible chat at POST /v1/chat/completions. Set the model to gpt-5.6-sol (gpt-5.6-terra and gpt-5.6-luna are the same generation; gpt-5.4 / gpt-5.4-mini are cheaper) and authenticate with Authorization: Bearer.
curl https://api.waytocc.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_OPENAI_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.6-sol","stream":true,"messages":[{"role":"user","content":"Introduce yourself in one sentence"}]}'The response matches OpenAI; text is at choices[0].message.content (delta.content when streaming). Use stream:true. Billed per token.
Gemini chat (native Gemini protocol)
Gemini uses Google's own API shape: POST /v1beta/models/{model}:generateContent, or :streamGenerateContent?alt=sse for streaming. Authenticate with x-goog-api-key and use the bare root as the base URL — the official SDK appends /v1beta itself.
curl "https://api.waytocc.com/v1beta/models/gemini-3-flash:streamGenerateContent?alt=sse" \
-H "x-goog-api-key: YOUR_GEMINI_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Introduce yourself in one sentence"}]}]}'⚠️ role is required inside contents — omitting it returns 400 INVALID_ARGUMENT rather than anything that names the missing field. The response matches Google exactly; text is at candidates[0].content.parts[0].text. Streaming is SSE with the same frame shape. Prefer streaming. Billed per token.
Using Claude Code
Because the chat API is Anthropic-compatible, the official Claude Code works by pointing its base URL here — two environment variables, using a key from the Claude group.
npm i -g @anthropic-ai/claude-code
export ANTHROPIC_BASE_URL=https://api.waytocc.com
export ANTHROPIC_AUTH_TOKEN=YOUR_CLAUDE_KEY
claudeANTHROPIC_BASE_URL takes the bare root (no /v1); ANTHROPIC_AUTH_TOKEN takes your key. Other Anthropic-compatible clients (Cline, the SDKs) work the same way.
Using Codex CLI
OpenAI's official Codex CLI connects directly — drop in the two files below (using a key from the ChatGPT group) and run codex in any project.
1. ~/.codex/config.toml (at the top of the file)
model_provider = "OpenAI"
model = "gpt-5.6-sol"
review_model = "gpt-5.6-sol"
model_reasoning_effort = "xhigh"
disable_response_storage = true
network_access = "enabled"
windows_wsl_setup_acknowledged = true
model_context_window = 1000000
model_auto_compact_token_limit = 900000
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.waytocc.com/v1"
wire_api = "responses"
requires_openai_auth = true2. ~/.codex/auth.json
{ "OPENAI_API_KEY": "YOUR_OPENAI_KEY" }base_url points at https://api.waytocc.com/v1 with model gpt-5.6-sol. Install with npm i -g @openai/codex. A 403 dispatch means the same thing as in GPT chat: move the key to the ChatGPT group.
Text to image
Give a prompt, get an image. POST /v1/images/generations with a JSON body. Copy any example below, swap in your key, run it.
curl -sS -m 185 https://api.waytocc.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "a red panda eating bamboo, studio lighting",
"n": 1,
"response_format": "b64_json"
}' \
| python3 -c "import sys,json,base64; d=json.load(sys.stdin); open('out.png','wb').write(base64.b64decode(d['data'][0]['b64_json'])); print('saved out.png')"On success the image is at data[0].b64_json — decode it and write the file.
Image to image
Send an image plus a prompt to edit it. POST /v1/images/edits as multipart/form-data (the image goes in the image field). Note the endpoint is plural: edits.
curl -sS -m 185 https://api.waytocc.com/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F model=gpt-image-2 \
-F [email protected] \
-F prompt="put the subject in a snowy forest at night" \
-F response_format=b64_json \
| python3 -c "import sys,json,base64; d=json.load(sys.stdin); open('out.png','wb').write(base64.b64decode(d['data'][0]['b64_json'])); print('saved out.png')"Swap input.png for your own file (PNG / JPG / WebP). The response shape matches text-to-image.
Parameters
modelYesAlways gpt-image-2 (note the -2).promptYesWhat to generate or change. The more specific, the better. Chinese is supported.imageFor editsThe source image, in the multipart image field (PNG/JPG/WebP).nNoHow many images. Defaults to 1.sizeNoA size preference (1024x1024 / 1024x1536 / 1536x1024 / auto). The actual output size is decided upstream and often differs; billing follows the actual output — see Pricing.response_formatNoUse b64_json (the default). url returns an internal address that clients cannot fetch.Response
A successful call returns 200 with the image at data[0].b64_json as raw base64 (no prefix to strip) — decode and write it straight to a file.
{
"created": 1781184210,
"data": [
{ "b64_json": "iVBORw0KGgoAAAANSUhEUg..." }
],
"usage": {
"input_tokens": 8,
"output_tokens": 0,
"total_tokens": 8
}
}Pricing
gpt-image-2 · 1K tierPer image¥0.13 eachgpt-image-2 · 2K tierPer image¥0.20 eachgpt-image-2 · 4K tierPer image¥0.27 eachChat (Claude / GPT / Gemini)Per tokenInput and output priced separatelyImages are billed per image at a flat rate — token usage is not part of the calculation. Prompt length and returned tokens don't change the price.
The tier follows the size of the image you actually get back, not the size parameter you sent: asking for 1024×1024 does not guarantee the 1K tier, and a size that can't be classified falls back to the 2K tier. Text-to-image and image-to-image cost the same; only the actual output size differs.
Chat is billed per token (input + output). Top up at ¥1 = $1; usage and spend are live in Usage history.
Base URL
Each protocol spells its base URL differently, because the official SDKs disagree about who appends the version segment:
https://api.waytocc.com/v1https://api.waytocc.comhttps://api.waytocc.comThe Anthropic and Gemini SDKs append /v1 and /v1beta themselves, so they take the bare root. The OpenAI SDK treats the base URL as already version-qualified, so it needs the /v1.
Common endpoints
Error codes
401Invalid keyWrong auth header or a deleted key. Check you copied it whole — and note Gemini uses x-goog-api-key, not Authorization.403No balance / not allowedOut of balance → top up; or the key's group doesn't serve this endpoint.429Rate limitedToo many requests at once. Lower concurrency and retry, or ask support to raise the limit.5xx / timeoutTransient upstream issueRetry with exponential backoff, 2–3 times. Set the client timeout to ≥180s.FAQ
Image generation is slow or times out.+
20–60 seconds per image is normal. Set your client timeout above 180 seconds (the examples use -m 185 / timeout=185). If it hangs indefinitely it's usually the network — try a different one.
Which sizes are supported? Why is the image a different size than I asked for?+
size accepts 1024x1024 / 1024x1536 / 1536x1024 / auto, but it is a preference, not a guarantee — the upstream model decides the real output size and it often differs. Billing follows the image you actually get, so requesting 1024x1024 does not guarantee the 1K tier. If cost matters, trust the charge shown in Usage history.
Should I use b64_json or url for response_format?+
Use b64_json (the default). You get the base64 directly and write it to disk. url returns an internal address that is not publicly reachable — don't depend on it.
Do I need to strip a prefix from b64_json?+
No. It is raw base64 — decode and write it (see the examples). There's no data:image/png;base64, prefix to remove.
Can I send multiple images to image-to-image?+
Upload via multipart in the image field; PNG/JPG/WebP all work. The endpoint is plural: /v1/images/edits. Describe the change you want in the prompt.
model not found?+
The image model ID must be gpt-image-2 (note the -2). Chat model names are listed in the sections above; a wrong name fails immediately.
How do I call Claude?+
POST /v1/messages (Anthropic-compatible) with model claude-opus-5, authenticating with x-api-key or Authorization: Bearer. The key must belong to the Claude group (image keys are separate) or you get 403 does not allow /v1/messages dispatch. See Claude chat above.
Can I call Gemini with the OpenAI SDK?+
No. Gemini uses Google's native protocol (/v1beta/models/...:generateContent with x-goog-api-key). Use the google-genai SDK or plain HTTP, pointing the base URL at https://api.waytocc.com. Calling /v1/chat/completions with the OpenAI SDK is rejected because the group's protocol doesn't match.
Does the official Claude Code work?+
Yes. export ANTHROPIC_BASE_URL=https://api.waytocc.com (the bare root, no /v1) and export ANTHROPIC_AUTH_TOKEN=<your Claude-group key>, then run claude. See Using Claude Code above.
Why do you recommend stream:true?+
A long non-streamed answer can hit a 524 timeout at the CDN edge after ~100 seconds. Streaming sends tokens as they're produced — no timeout, and it feels faster.
Stuck? Talk to us
Connection problems, errors, balance questions — reach out.