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/v1 and Anthropic clients at https://api.halfbill.uk, authenticate with your HALFBILL_API_KEY, and pick a model such as claude-sonnet-5 or gpt-5.5.


1 · Create an account and add credits

  1. Sign up at halfbill.uk.
  2. 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

  1. Open the dashboard, pick a project, and create a key. Optionally set a spend limit on it.
  2. Export it in your shell (or a .env file):
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
claude

If an existing ANTHROPIC_API_KEY causes an authentication conflict, unset it in that shell first. The full walkthrough is in the Claude Code guide.

  1. Open Cursor Settings → Models.
  2. Under OpenAI API Key, paste your Halfbill key and turn on Override OpenAI Base URL; set it to https://api.halfbill.uk/v1.
  3. Add the models you want to use by their Halfbill ids, for example gpt-5.5 and claude-sonnet-5, then enable them.
  4. Click Verify. Cursor sends a test request through Halfbill.

Details and troubleshooting are in the Cursor guide.


Going further

  • Streaming: pass stream: true to 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

How is this guide?

On this page