Models → Pricing → Docs → Blog → Changelog → Contact → Status →
Get started freeLog in

Migrate from the Anthropic SDK to FreeModel

Point the Anthropic SDK and Claude Code at FreeModel: base URL without /v1, fm_ key auth, Claude model ids and multipliers, paid plan, and what differs.

FreeModel serves the Anthropic Messages format at https://freemodel.in (/v1/messages and /v1/messages/count_tokens). The official Anthropic SDKs, Claude Code and Claude Desktop work with it. This guide moves an existing Anthropic SDK integration over, step by step, and lists what behaves differently.

Claude models other than Claude Haiku 5.5 need a paid plan. The free tokens work only on the free models; a free key asking for another Claude model gets a 403. FreeModel is an independent service and is not affiliated with Anthropic.

Step 1: get a key and a plan

  1. Create a key at dashboard → API keys. It starts with fm_.
  2. Buy any paid plan on pricing — Starter ($1.20 for 30M tokens, 30 days) is enough to test. Every paid plan reaches every model.

Step 2: change the client (Python)

import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["FREEMODEL_API_KEY"],
    base_url="https://freemodel.in",          # no /v1 — the SDK adds it
)

msg = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    system="You are a concise assistant.",
    messages=[{"role": "user", "content": "Explain HTTP 529 in one sentence."}],
)
print(msg.content[0].text)
print(msg.usage.input_tokens, msg.usage.output_tokens)

Use the bare domain, not /v1: the Anthropic SDK appends /v1/messages itself. (The OpenAI SDK is the opposite — there the base URL ends in /v1.)

The SDK also reads ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL from the environment, so an app that creates anthropic.Anthropic() without arguments can be moved with two environment variables.

Step 3: change the client (Node)

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.FREEMODEL_API_KEY,
  baseURL: "https://freemodel.in",
});

const msg = await client.messages.create({
  model: "claude-sonnet-5",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude" }],
});
console.log(msg.content[0].text);

Authentication works with the SDK's default x-api-key header; Authorization: Bearer is accepted too.

Step 4: use Claude ids we list

Use the ids from the models page exactly. Each model uses plan tokens at its own multiplier:

IdMultiplierListed context
claude-opus-5-53×1M
claude-opus-53×1M
claude-sonnet-53×1M
claude-opus-4.83×1M
claude-haiku-5.51.5×1M

Names we do not list — claude-3-5-sonnet, claude-3-opus and the like — return 404 model_not_found. They are never mapped to another model, so an old id fails loudly instead of quietly answering with something else.

Step 5: streaming

Streaming works the same way as with Anthropic directly:

with client.messages.stream(
    model="claude-sonnet-5",
    max_tokens=2048,
    messages=[{"role": "user", "content": "Write a haiku about migrations."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Claude Code and Claude Desktop

Claude Code uses the same endpoint. Set these before starting it:

export ANTHROPIC_BASE_URL=https://freemodel.in
export ANTHROPIC_AUTH_TOKEN=fm_your_key_here
export ANTHROPIC_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5
claude

ANTHROPIC_DEFAULT_HAIKU_MODEL is not optional: Claude Code runs background tasks on a small model, and that model must also be one we list. You can pick the main model with --model instead of ANTHROPIC_MODEL. More detail in using Claude Code with a custom API and the coding agents docs.

What differs

TopicOn FreeModel
BillingPrepaid 30-day plans of tokens; each model at its multiplier; input and output both count
Tokens used up402 billing_error with a clear message; nothing charged on top
Free account, Claude model other than Haiku 5.5403 permission_error; the message lists the free models
Model temporarily unavailable529 overloaded_error with Retry-After: 3; the SDK retries it
Rate limitsRequests per minute per plan, across all keys (details)
count_tokensReturns an estimate from text length; does not run the model
Prompt cachingInput tokens count whether cached or not (details)

Anthropic-format errors carry type and message but no separate code field, so read the message to tell, say, a used-up plan from a key spend limit:

try:
    msg = client.messages.create(model="claude-sonnet-5", max_tokens=512,
                                 messages=[{"role": "user", "content": "Hi"}])
except anthropic.PermissionDeniedError as err:    # 403: paid plan needed, or key scope
    print("Not allowed:", err.message)
except anthropic.APIStatusError as err:
    if err.status_code == 402:                    # tokens used up — do not retry
        print("Plan tokens used up:", err.message)
    else:
        raise

Tool use keeps its shape

Tool definitions use the same Anthropic shape — name, description, input_schema — and the reply carries tool_use blocks that you answer with tool_result blocks, as before:

tools = [{
    "name": "get_order_status",
    "description": "Look up the status of an order by its id.",
    "input_schema": {"type": "object",
                     "properties": {"order_id": {"type": "string"}},
                     "required": ["order_id"]},
}]

msg = client.messages.create(
    model="claude-sonnet-5", max_tokens=1024, tools=tools,
    messages=[{"role": "user", "content": "Where is order A-1042?"}],
)
for block in msg.content:
    if block.type == "tool_use":
        print(block.name, block.input)      # run it, then send a tool_result

Testing the switch

  1. Run your test suite against FreeModel with one Claude id, for example claude-haiku-5.5 to keep plan-token use low (1.5×).
  2. Compare usage on a few real requests with what you expect, multiplier included.
  3. Check your peak requests per minute against your plan's limit.
  4. Only then move production traffic, one service at a time.

The same models through the OpenAI format

If parts of your stack use the OpenAI SDK, the same Claude ids also work on https://freemodel.in/v1/chat/completions. One key covers both formats — see migrating from the OpenAI SDK.

FAQ

Can I use Claude models on the free plan?

Only Claude Haiku 5.5. The other Claude models need a paid plan. A free key gets 403 for them. Free tokens work only on the free models.

Should the base URL include /v1?

No. The Anthropic SDK adds /v1/messages itself, so the documented setting is https://freemodel.in without /v1.

Will claude-3-5-sonnet still work?

No. Model names we do not list return 404 model_not_found and are never mapped to another model. Use an id from the models page.

Which Claude Code settings do I need?

ANTHROPIC_BASE_URL=https://freemodel.in, ANTHROPIC_AUTH_TOKEN set to your key, a model via --model or ANTHROPIC_MODEL, and ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-5-5.

Ready to build?

Grab a free API key — 1M tokens on 8 free models after a one-time Telegram verification, no card. Every model from $1.20.