Quickstart
Three steps to your first Halfbill request, with snippets for cURL, Python, TypeScript, the Anthropic SDK, Claude Code, and Cursor.
Not a developer? Start here → — plain-language guides for the chat, Claude Code, Cursor, and credits.
Halfbill is a drop-in base URL for Anthropic Claude and OpenAI GPT models. Keep your SDK and your code; change the base URL and the key.
TL;DR — Point OpenAI-compatible clients at
https://api.halfbill.uk/v1and Anthropic clients athttps://api.halfbill.uk, authenticate with yourHALFBILL_API_KEY, and pick a model such asclaude-sonnet-5orgpt-5.5.
1 · Create an account and add credits
- Sign up at halfbill.uk.
- Add credits from the billing page — pay as you go, no subscription required — or pick a Chat or Code plan. See Pricing & billing.
2 · Create an API key
- Open the dashboard, pick a project, and create a key. Optionally set a spend limit on it.
- Export it in your shell (or a
.envfile):
export HALFBILL_API_KEY="your_api_key"3 · Set the base URL
curl https://api.halfbill.uk/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $HALFBILL_API_KEY" \
-d '{
"model": "claude-sonnet-5",
"messages": [
{"role": "user", "content": "Hello, how are you?"}
]
}'# pip install openai
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.halfbill.uk/v1",
api_key=os.environ["HALFBILL_API_KEY"],
)
completion = client.chat.completions.create(
model="gpt-5.5",
messages=[{"role": "user", "content": "Hello, how are you?"}],
)
print(completion.choices[0].message.content)// npm install openai
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.halfbill.uk/v1",
apiKey: process.env.HALFBILL_API_KEY,
});
const completion = await client.chat.completions.create({
model: "claude-sonnet-5",
messages: [{ role: "user", content: "Hello, how are you?" }],
});
console.log(completion.choices[0].message.content);The Anthropic SDK appends /v1/messages itself, so the base URL has no /v1 suffix.
# pip install anthropic
import os
import anthropic
client = anthropic.Anthropic(
base_url="https://api.halfbill.uk",
api_key=os.environ["HALFBILL_API_KEY"],
)
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello, how are you?"}],
)
print(message.content[0].text)// npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.halfbill.uk",
apiKey: process.env.HALFBILL_API_KEY,
});
const message = await client.messages.create({
model: "claude-sonnet-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello, how are you?" }],
});
console.log(message.content);Set the variables in the shell where you launch Claude Code. ANTHROPIC_BASE_URL has no /v1 suffix; Claude Code adds /v1/messages itself.
export ANTHROPIC_BASE_URL=https://api.halfbill.uk
export ANTHROPIC_AUTH_TOKEN="$HALFBILL_API_KEY"
export ANTHROPIC_MODEL=claude-sonnet-5
claudeIf an existing ANTHROPIC_API_KEY causes an authentication conflict, unset it in that shell first. The full walkthrough is in the Claude Code guide.
- Open Cursor Settings → Models.
- Under OpenAI API Key, paste your Halfbill key and turn on Override OpenAI Base URL; set it to
https://api.halfbill.uk/v1. - Add the models you want to use by their Halfbill ids, for example
gpt-5.5andclaude-sonnet-5, then enable them. - Click Verify. Cursor sends a test request through Halfbill.
Details and troubleshooting are in the Cursor guide.
Going further
- Streaming: pass
stream: trueto any request; the event stream is proxied unchanged. - Tool calls, vision, structured outputs: use them exactly as with the vendor SDK.
- Prompt caching on Claude: see Provider cache control.
- Monitoring: every call appears in the dashboard with tokens, cost, and latency.
FAQ
Next steps
- Coding agents: Claude Code, Cursor, Codex CLI, Cline, Continue
- Reference: Rate limits, Error handling, API keys
- Questions: support@halfbill.uk
How is this guide?