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 body | JSON, 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).
| Method | Path | Description | Billing |
|---|---|---|---|
| GET | /v1/models | The models your account can use: context and input/output limits, reasoning effort, official prices and multipliers | Free |
| POST | /v1/messages | Anthropic Messages API, every model (Claude, GPT, DeepSeek / GLM / Kimi and more) | Usage-based |
| POST | /v1/messages/count_tokens | Estimates the input tokens of a Messages request | Free |
| POST | /v1/responses | OpenAI Responses API, GPT models (used by Codex CLI) | Usage-based |
| POST | /v1/images/generations | OpenAI Images API: generate images from text (gpt-image-2.6) | Usage-based |
| POST | /v1/images/edits | OpenAI Images API: edit or combine reference images | Usage-based |
| GET | /v1/account | Account balance and total usage | Free |
| GET | /v1/usage | Recent requests | Free |
| GET | /health | Service status, no key needed | Free |
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:
| Field | Description |
|---|---|
id | The model name, the value for model in requests |
display_name / description | Display name and short description |
owned_by | The 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) |
vendor | The model's vendor, only on models of the Gemini, DeepSeek and CodeBuddy routes, e.g. Google, DeepSeek |
created_at / lifecycle / line | Release date (1970-01-01T00:00:00Z when unknown), status (active), family (opus, sonnet etc. for Claude, null for the others) |
context_window | Context window, GPT models only |
max_input_tokens | Maximum input tokens |
max_tokens | Maximum output tokens |
capabilities | image_input, pdf_input (whether it takes images and PDFs), effort (which reasoning efforts it supports), thinking (the thinking types Claude supports) |
supported_reasoning_levels | The supported reasoning efforts with descriptions, e.g. [{"effort":"low","description":"..."}] |
default_reasoning_level | The effort used when none is given |
pricing | Official 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 |
rates | The multipliers of the upstream groups you can use, e.g. [{"name":"Default","multiplier":1}]; the actual charge = official price × multiplier |
sources | The 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.
| Parameter | Type | Description |
|---|---|---|
model | string | Required. 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_tokens | integer | Required. Maximum output tokens, also used to estimate the amount held |
messages | array | Required. The conversation; content can be text, images, PDFs, tool calls and tool results |
system | string / array | System prompt |
stream | boolean | true streams the reply as SSE: message_start, content_block_start / delta / stop, message_delta, message_stop |
tools / tool_choice | Tool definitions and choice, as in Anthropic's API | |
thinking | object | Thinking settings, e.g. {"type":"adaptive"}; the types each model supports are in capabilities.thinking of /v1/models |
output_config.effort | string | Reasoning 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.
| Parameter | Type | Description |
|---|---|---|
model | string | A GPT model, e.g. gpt-6.2-astra; defaults to gpt-6.1-sol |
input | string / array | The input: a string, or OpenAI input items (messages, tool call results and so on) |
instructions | string | System prompt; defaults to “You are a helpful assistant.” |
tools / tool_choice / parallel_tool_calls | Tools, as in OpenAI's API | |
reasoning | object | Reasoning settings, e.g. {"effort":"high","summary":"auto"} |
stream | boolean | Defaults to true: SSE with OpenAI's events (response.output_text.delta, response.completed and so on); false returns the complete response object |
prompt_cache_key | string | Use 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.
| Parameter | Type | Description |
|---|---|---|
prompt | string | Required. What the image should show, up to 32,000 characters |
model | string | Defaults to gpt-image-2.6; gpt-image-2 works too and is the same model |
n | integer | How 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 |
size | string | auto (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 |
quality | string | low, 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 |
background | string | transparent, opaque, auto (default) |
stream | boolean | true 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.pngPOST /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.pngGET /v1/account
Account balance and total usage
Returns {"object":"account","account":{...}}:
| Field | Description |
|---|---|
id / name / email | The account |
balance_usd | Balance |
reserved_usd | The amount held for requests in progress |
available_usd | Available balance = balance − held |
request_count | Total requests |
input_tokens / output_tokens | Total input and output tokens |
cache_read_input_tokens / cache_creation_input_tokens | Total cache-read and cache-write tokens |
created_at / updated_at | When 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:
| Field | Description |
|---|---|
request_id / model / status | Request ID, model, status (completed, error, cancelled) |
api_key_id / api_key_prefix | The key it used |
input_tokens / output_tokens | Input and output tokens |
cache_read_input_tokens / cache_creation_input_tokens | Cache-read and cache-write tokens (writes also split into _5m and _1h) |
cost_usd | What the request cost (also as cost_micros) |
pricing | The unit prices, tier and multiplier it was settled at |
duration_ms / error / created_at | Duration, 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":"..."}}
| Status | type | Meaning |
|---|---|---|
400 | invalid_request_error | Bad request body, or this endpoint doesn't serve the requested model (the message lists the ones it does) |
401 | authentication_error | No key, or the key is invalid or disabled |
402 | billing_error | Your available balance can't cover the hold for this request; please top up |
403 | permission_error | The account has been disabled |
404 | not_found_error | No such endpoint |
413 | request_too_large | Request body too large |
429 | rate_limit_error | Rate limited upstream: if there's a retry-after header, wait that many seconds and retry |
500 / 502 / 503 / 529 | api_error / overloaded_error | Upstream error or temporarily unavailable; retry later |