Recharge bonus$3 free with ¥30+ · $8 free with ¥50+ · $20 free with ¥100+ · $50 free with ¥200+ · $150 free with ¥500+ · New users get 20% extra on their first recharge (up to $200)Ends Dec 31, 15:09 (UTC+8)Recharge →

7bit API docs

How to use the 7bit API in Claude Code, Codex CLI, claude-pro, the Anthropic / OpenAI SDKs and other compatible clients, and every endpoint's parameters and responses. First sign up in the dashboard, create a key under “API keys”, and put it wherever <your API key> appears below.

Base URL and authentication

Base URL (Anthropic-style clients)https://7bit.fun
Base URL (OpenAI-style clients)https://7bit.fun/v1
Authentication (either one)x-api-key: <Key> or Authorization: Bearer <Key>
Request bodyJSON, content-type: application/json

Requests and spending are tracked per key, so you can create one for each project or device and disable any of them at any time.

Using Claude Code

Install Claude Code first (it needs Node.js 18 or later; on Windows, installing Git for Windows too is recommended):

npm install -g @anthropic-ai/claude-code

Set two environment variables, then run claude. No Anthropic account needed. macOS / Linux:

export ANTHROPIC_BASE_URL=https://7bit.fun
export ANTHROPIC_AUTH_TOKEN=<your API key>
claude

Windows PowerShell:

$env:ANTHROPIC_BASE_URL="https://7bit.fun"
$env:ANTHROPIC_AUTH_TOKEN="<your API key>"
claude

To make it permanent, put it in ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json; if the file already has other settings, just add the two entries under env):

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://7bit.fun",
    "ANTHROPIC_AUTH_TOKEN": "<your API key>"
  }
}

If it asks you to log in after starting, the settings haven't taken effect: check the file above. Switch models with /model; for GPT, DeepSeek and other models you can also type the model name, e.g. /model gpt-6.2-astra. /status shows that you're connected to this site.

Using Codex CLI

Install Codex CLI (it needs Node.js 18 or later):

npm install -g @openai/codex

Put the following in (or merge it into) ~/.codex/config.toml, on Windows %USERPROFILE%\.codex\config.toml:

# ~/.codex/config.toml
model = "gpt-6.2-astra"
model_provider = "gateway"

[model_providers.gateway]
name = "gateway"
base_url = "https://7bit.fun/v1"
wire_api = "responses"
env_key = "GATEWAY_API_KEY"

Then put your key in the GATEWAY_API_KEY environment variable and run codex. macOS / Linux:

export GATEWAY_API_KEY=<your API key>
codex

Windows (setx applies to terminals opened afterwards, so reopen PowerShell after running it):

setx GATEWAY_API_KEY "<your API key>"

Through the Responses API, Codex can only use GPT models: switch with /model in Codex or change model in config.toml. For Claude models, use Claude Code or claude-pro.

claude-pro

An open-source command-line coding agent much like Claude Code that runs on your 7bit balance and comes with a local web dashboard. It installs with one command, no Node.js needed beforehand:

# Windows (PowerShell)
irm https://7bit.fun/claude-pro/install.ps1 | iex

# macOS / Linux
curl -fsSL https://7bit.fun/claude-pro/install.sh | sh

Start claude-pro, run /connect, choose 7bit.fun and paste your key. Features and full install steps are on the claude-pro page.

Other clients

Clients that let you set a custom Anthropic Base URL (Cline, Cherry Studio, LobeChat and others): set the address to https://7bit.fun and the key to your API key. Clients that support the OpenAI Responses API, or only OpenAI Chat Completions (all kinds of OpenAI-compatible tools): set the Base URL to https://7bit.fun/v1. For the model name, use an id from Pricing, or read them from /v1/models.

SDK

Anthropic Python SDK:

import anthropic

client = anthropic.Anthropic(base_url="https://7bit.fun", api_key="<your API key>")
message = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)

Generating an image with the OpenAI Python SDK:

import base64
from openai import OpenAI

client = OpenAI(base_url="https://7bit.fun/v1", api_key="<your API key>")
image = client.images.generate(
    model="gpt-image-2.6",
    prompt="a red fox in the snow, flat vector illustration",
    size="1024x1024",
    quality="low",
)
with open("fox.png", "wb") as f:
    f.write(base64.b64decode(image.data[0].b64_json))

API reference

Requests and responses have the same format as Anthropic's and OpenAI's official APIs, with streaming (SSE), tool use, and image and PDF input. The examples are curl commands for bash (macOS, Linux; on Windows, use Git Bash or WSL).

MethodPathDescriptionBilling
GET/v1/modelsThe models your account can use: context and input/output limits, reasoning effort, official prices and multipliersFree
POST/v1/messagesAnthropic Messages API, every model (Claude, GPT, DeepSeek / GLM / Kimi and more)Usage-based
POST/v1/messages/count_tokensEstimates the input tokens of a Messages requestFree
POST/v1/responsesOpenAI Responses API, GPT models (used by Codex CLI)Usage-based
POST/v1/images/generationsOpenAI Images API: generate images from text (gpt-image-2.6)Usage-based
POST/v1/images/editsOpenAI Images API: edit or combine reference imagesUsage-based
GET/v1/accountAccount balance and total usageFree
GET/v1/usageRecent requestsFree
GET/healthService status, no key neededFree

GET /v1/models

The models your account can use: context and input/output limits, reasoning effort, official prices and multipliers

Lists only the models the key's account can use (which depends on the account's upstream group). The fields are those of Anthropic's official Models API, plus OpenAI's object / owned_by, reasoning-effort descriptions, official prices and multipliers. The envelope is {"object":"list","data":[...],"has_more":false,"first_id":...,"last_id":...}; each model in data has:

FieldDescription
idThe model name, the value for model in requests
display_name / descriptionDisplay name and short description
owned_byThe route that serves it: anthropic (Claude), openai (GPT), google (Gemini, through Google Antigravity), deepseek (DeepSeek's official API), codebuddy (DeepSeek, GLM, Kimi and more), custom (other OpenAI / Anthropic-compatible upstreams connected to the gateway)
vendorThe model's vendor, only on models of the Gemini, DeepSeek and CodeBuddy routes, e.g. Google, DeepSeek
created_at / lifecycle / lineRelease date (1970-01-01T00:00:00Z when unknown), status (active), family (opus, sonnet etc. for Claude, null for the others)
context_windowContext window, GPT models only
max_input_tokensMaximum input tokens
max_tokensMaximum output tokens
capabilitiesimage_input, pdf_input (whether it takes images and PDFs), effort (which reasoning efforts it supports), thinking (the thinking types Claude supports)
supported_reasoning_levelsThe supported reasoning efforts with descriptions, e.g. [{"effort":"low","description":"..."}]
default_reasoning_levelThe effort used when none is given
pricingOfficial prices in USD / 1M tokens: input_per_million_usd, output_per_million_usd, cache_read_per_million_usd, cache_write_5m_per_million_usd, cache_write_1h_per_million_usd; long_context: the prices the whole request is billed at when the prompt exceeds threshold_tokens; off_peak: off-peak prices (DeepSeek); source_url, verified_at: where the prices come from and when they were checked
ratesThe multipliers of the upstream groups you can use, e.g. [{"name":"Default","multiplier":1}]; the actual charge = official price × multiplier
sourcesThe upstream platforms that serve this model: [{"platform":"deepseek","name":"DeepSeek (official API)","rates":[...]}]. platform takes the same values as owned_by, and rates are the multipliers you can use on that platform. Most models have one; those that both DeepSeek's official API and CodeBuddy serve have two: a new conversation starts on the first (the lower multiplier), and a conversation stays on the platform that served it last

Example:

curl "https://7bit.fun/v1/models" -H "x-api-key: <your API key>"

POST /v1/messages

Anthropic Messages API, every model (Claude, GPT, DeepSeek / GLM / Kimi and more)

This is what Claude Code and claude-pro use, and it works with every model: Claude models go to Anthropic; models of DeepSeek's official API (owned_by deepseek) are passed as-is to DeepSeek's Anthropic-compatible API; GPT models are converted and sent through Codex, Gemini models through Google Antigravity, and GLM, Kimi and the like through CodeBuddy, with their replies converted back to the Anthropic format. The anthropic-version header is optional.

ParameterTypeDescription
modelstringRequired. An id from /v1/models, optionally with a reasoning-effort suffix, e.g. glm-5.3:max. Older Claude models (e.g. claude-opus-4-6) are served by the current model of the same family and billed at its price
max_tokensintegerRequired. Maximum output tokens, also used to estimate the amount held
messagesarrayRequired. The conversation; content can be text, images, PDFs, tool calls and tool results
systemstring / arraySystem prompt
streambooleantrue streams the reply as SSE: message_start, content_block_start / delta / stop, message_delta, message_stop
tools / tool_choiceTool definitions and choice, as in Anthropic's API
thinkingobjectThinking settings, e.g. {"type":"adaptive"}; the types each model supports are in capabilities.thinking of /v1/models
output_config.effortstringReasoning effort: low, medium, high, xhigh, max (some GPT models also have ultra), mapped to the nearest level the model supports; defaults to the model's default level

Other fields are as in Anthropic's official Messages API. Returns an Anthropic Message object whose usage has the actual usage: input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens.

Example:

curl "https://7bit.fun/v1/messages" \
  -H "x-api-key: <your API key>" \
  -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-4-5","max_tokens":256,"messages":[{"role":"user","content":"Hello"}]}'

POST /v1/messages/count_tokens

Estimates the input tokens of a Messages request

Doesn't call a model and is free. The request body is the same as for /v1/messages (model, messages, system, tools; no max_tokens needed), and it returns {"input_tokens": 1234}. This is the gateway's estimate from the length of the text (about 3.6 characters per token), so it can differ from the tokens actually billed.

Example:

curl "https://7bit.fun/v1/messages/count_tokens" \
  -H "x-api-key: <your API key>" \
  -H "content-type: application/json" \
  -d '{"model":"claude-sonnet-4-5","messages":[{"role":"user","content":"Hello"}]}'

POST /v1/responses

OpenAI Responses API, GPT models (used by Codex CLI)

For GPT models only (those with owned_by openai in /v1/models); this is what Codex CLI's wire_api = "responses" uses. Requests are passed to Codex as-is, and its events come back as-is.

ParameterTypeDescription
modelstringA GPT model, e.g. gpt-6.2-astra; defaults to gpt-6.1-sol
inputstring / arrayThe input: a string, or OpenAI input items (messages, tool call results and so on)
instructionsstringSystem prompt; defaults to “You are a helpful assistant.”
tools / tool_choice / parallel_tool_callsTools, as in OpenAI's API
reasoningobjectReasoning settings, e.g. {"effort":"high","summary":"auto"}
streambooleanDefaults to true: SSE with OpenAI's events (response.output_text.delta, response.completed and so on); false returns the complete response object
prompt_cache_keystringUse the same value for the whole conversation to get more cache hits

Not supported and ignored: max_output_tokens, temperature, top_p, metadata, user, truncation, service_tier, background, previous_response_id, max_tool_calls, top_logprobs, safety_identifier, stream_options, prompt_cache_retention, conversation. Responses aren't stored on the server (store is always false), so to continue a conversation, send the full input again.

Example:

curl "https://7bit.fun/v1/responses" \
  -H "Authorization: Bearer <your API key>" \
  -H "content-type: application/json" \
  -d '{"model":"gpt-6.2-astra","input":"Hello","stream":false}'

POST /v1/images/generations

OpenAI Images API: generate images from text (gpt-image-2.6)

The same as OpenAI's official Images API: returns base64-encoded PNG images. They're made by the same image model ChatGPT uses (Images 2.6; ChatGPT picks the Sunburst or Flare variant, which you can't choose; SVG, GIF and xhigh / max quality aren't supported). An image usually takes 10–45 seconds.

ParameterTypeDescription
promptstringRequired. What the image should show, up to 32,000 characters
modelstringDefaults to gpt-image-2.6; gpt-image-2 works too and is the same model
nintegerHow many images, 1–10, default 1. Each is billed on its own and is a row of its own in the usage log; one that fails is free and left out of the response
sizestringauto (default) or WIDTHxHEIGHT, e.g. 1024x1024, 1536x1024, 1024x1536, between 1:3 and 3:1. It sets the shape only: the model picks the pixels (a square image is usually 1254x1254), and size in the response is the actual size
qualitystringlow, medium, high, auto (default). Higher quality takes more output tokens and costs more. It's a hint: the model sometimes uses another level (e.g. medium for low); quality in the response is the level actually used, and you're billed for the tokens actually used
backgroundstringtransparent, opaque, auto (default)
streambooleantrue streams SSE: an image_generation.completed event as each image is done (no partial_image)

Not supported: response_format can only be b64_json (no image URLs); output_format always comes back as PNG; moderation, output_compression and user are ignored. Returns {"created":...,"data":[{"b64_json":"..."}],"background":"opaque","output_format":"png","quality":"low","size":"1254x1254","usage":{...}}, where usage has input_tokens (split into text and images in input_tokens_details), output_tokens and total_tokens.

Example (jq takes the image out and saves it):

curl "https://7bit.fun/v1/images/generations" \
  -H "Authorization: Bearer <your API key>" \
  -H "content-type: application/json" \
  -d '{"model":"gpt-image-2.6","prompt":"a red fox in the snow, flat vector illustration","size":"1024x1024","quality":"low"}' \
  | jq -r '.data[0].b64_json' | base64 --decode > fox.png

POST /v1/images/edits

OpenAI Images API: edit or combine reference images

Edit or combine reference images, up to 5 (PNG, JPEG, WebP). Two ways to send them: multipart/form-data with files named image or image[] (what the OpenAI SDK's images.edit sends), or JSON with "images": [{"image_url": "data:image/png;base64,..."}], which also takes http(s) URLs. The other parameters and the response are as for generation (the stream's event is image_edit.completed). mask isn't supported: describe what to change in the prompt. Reference images are billed at the image input price; a 1254x1254 one is about 1,500 tokens.

Example:

curl "https://7bit.fun/v1/images/edits" \
  -H "Authorization: Bearer <your API key>" \
  -F model=gpt-image-2.6 \
  -F "image[]=@fox.png" \
  -F prompt="make it night with an aurora" \
  | jq -r '.data[0].b64_json' | base64 --decode > fox-night.png

GET /v1/account

Account balance and total usage

Returns {"object":"account","account":{...}}:

FieldDescription
id / name / emailThe account
balance_usdBalance
reserved_usdThe amount held for requests in progress
available_usdAvailable balance = balance − held
request_countTotal requests
input_tokens / output_tokensTotal input and output tokens
cache_read_input_tokens / cache_creation_input_tokensTotal cache-read and cache-write tokens
created_at / updated_atWhen it was created and last updated

Each amount also comes as a *_micros field: an integer in millionths of a dollar. Example:

curl "https://7bit.fun/v1/account" -H "x-api-key: <your API key>"

GET /v1/usage

Recent requests

The account's recent requests (from all its keys), newest first. Parameter limit: 1–1000, default 100. Returns {"data":[...],"account":{...}}, where account is as in /v1/account; each request has:

FieldDescription
request_id / model / statusRequest ID, model, status (completed, error, cancelled)
api_key_id / api_key_prefixThe key it used
input_tokens / output_tokensInput and output tokens
cache_read_input_tokens / cache_creation_input_tokensCache-read and cache-write tokens (writes also split into _5m and _1h)
cost_usdWhat the request cost (also as cost_micros)
pricingThe unit prices, tier and multiplier it was settled at
duration_ms / error / created_atDuration, error reason, time

Example:

curl "https://7bit.fun/v1/usage?limit=5" -H "x-api-key: <your API key>"

GET /health

Service status, no key needed

No key needed; returns {"ok":true,"service":"codex-gateway","version":"...","upstream_mode":"claude-code","multi_user":true}.

curl "https://7bit.fun/health"

Billing

The charge = the model's official price × your upstream group's multiplier; see Pricing, or pricing and rates in /v1/models. When a request starts, an estimate (the estimated input + max_tokens, at the highest multiplier) is held from your balance, and if the available balance can't cover it you get a 402 right away; when it ends, it's settled by the actual tokens and the excess hold is refunded. Failed requests are free; a request cut off midway is charged for the tokens already used. Every request is itemized in the dashboard's usage log.

Errors

An error before the response starts comes back as an HTTP status code from the table below with Anthropic-style JSON (the same for all three API formats); an error in the middle of a stream comes in the stream: an error event for Messages, a response.failed event for Responses, and a chunk with error for Chat Completions.

{"type":"error","error":{"type":"invalid_request_error","message":"..."}}
StatustypeMeaning
400invalid_request_errorBad request body, or this endpoint doesn't serve the requested model (the message lists the ones it does)
401authentication_errorNo key, or the key is invalid or disabled
402billing_errorYour available balance can't cover the hold for this request; please top up
403permission_errorThe account has been disabled
404not_found_errorNo such endpoint
413request_too_largeRequest body too large
429rate_limit_errorRate limited upstream: if there's a retry-after header, wait that many seconds and retry
500 / 502 / 503 / 529api_error / overloaded_errorUpstream error or temporarily unavailable; retry later