Move from the Claude API to an open model

By Loïc Jané, founder of Frontière AI

Published 2026-12-03 · 8 min read

You can keep the Anthropic SDK and the code built on it. Point the client at https://getfrontiereai.eu/api, use a Frontière AI key, and replace the Claude model id with an open model such as glm-5.3. Messages, system prompts, tools, images and streaming are translated; Claude's thinking blocks, prompt-cache markers and Anthropic's server-side tools are not. Before moving traffic, rerun a sample of your real requests and compare the answers and the tokens billed: open models that reason at length can write several times more output tokens than Claude for the same task.

Change three lines

Frontière AI exposes the Anthropic Messages format at https://getfrontiereai.eu/api/v1/messages, next to the OpenAI-compatible endpoint. The Anthropic SDKs add /v1/messages to the base URL themselves, so the base URL stops at /api. The key can be sent the way the SDK sends it, as x-api-key, or as Authorization: Bearer; both are accepted. Then change the model id to one from our catalogue.

In Python:

import os
import anthropic

client = anthropic.Anthropic(
    base_url="https://getfrontiereai.eu/api",
    api_key=os.environ["FRONTIERE_API_KEY"],
)

message = client.messages.create(
    model="glm-5.3",
    max_tokens=8192,
    system="You answer customer questions about invoices.",
    messages=[{"role": "user", "content": "Why was I charged twice?"}],
)
print(message.content[0].text)

In TypeScript:

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

const client = new Anthropic({
  baseURL: "https://getfrontiereai.eu/api",
  apiKey: process.env.FRONTIERE_API_KEY,
});

const message = await client.messages.create({
  model: "glm-5.3",
  max_tokens: 8192,
  messages: [{ role: "user", content: "Summarise this ticket." }],
});

Nothing else in the call has to change. The response comes back in Anthropic's format, with the same content blocks, the same stop reasons (end_turn, max_tokens, tool_use) and a usage object. Errors come back in Anthropic's error format too, with the status code kept, so the SDK's automatic retries on rate-limit and overload errors keep working. Two extra response headers tell you which provider served the request and whether that route is EU sovereign: x-routed-provider and x-sovereign.

Which model to pick

Start from the work, not the name. For an agent or for code, pick a large model whose tool calling worked in our tests, such as GLM-5.3 or Kimi K3.1 Pro. For classification, extraction and short answers, a smaller model is often enough, at a fraction of the cost. GPT-OSS 120B passed 40 of the 42 exercises of our Code Bench while writing few tokens, which makes it a good first test for that kind of work.

Our measured comparison with Claude gives the scores and the cost of the same run on each model. The catalogue gives each model's context window, whether it reads images, and which European provider serves it. Keep two candidates and test both on your own requests: the gap between models on your work matters more than their rank on a general leaderboard.

What carries over

The endpoint translates each request to the format the open models are served in, then translates the answer back. These parts of a request are translated:

  • System prompt: a string or text blocks.
  • Messages: text, and images sent as base64 or as a URL, for models that read images.
  • Tools: your tool definitions and their input schemas, tool_use blocks in the assistant's turns and tool_result blocks in yours, including results flagged as errors. tool_choice is translated for auto, any, none and a named tool.
  • Documents sent as text: a document block whose source is plain text, with its title.
  • Sampling and limits: max_tokens, temperature, top_p, top_k, and up to four stop_sequences.
  • Streaming: the full sequence of Anthropic stream events, including tool calls that arrive in pieces.

Usage follows Anthropic's convention: input_tokens excludes the tokens read from the provider's cache, which are reported in cache_read_input_tokens. If your code computes costs from usage, it keeps working; only the prices change. The count_tokens endpoint answers too, but with an estimate of about four characters per token, never the amount billed.

What does not

Some features exist only on Anthropic's own servers, or only for Claude models. They are accepted without error and ignored, or they are not available:

  • Thinking: the thinking parameter is ignored, and thinking blocks in the conversation history are not passed on. Their signature only means something to Anthropic.
  • Prompt caching markers: cache_control is ignored. The providers cache repeated prompt prefixes on their own, and the tokens read from cache are reported in usage.
  • Server-side tools: Anthropic's web search, web fetch and code execution tools run on Anthropic's servers. Tools without an input schema are dropped; give the model your own tool instead.
  • Binary documents: a PDF sent as base64 is not forwarded to the provider. The model sees a short note that a binary document was attached, so extract the text first and send it as text.
  • Other Anthropic options: settings that are not listed above, such as effort or structured output settings, are not passed on. disable_parallel_tool_use is not passed on either.
  • Other Anthropic APIs: the Message Batches API, the Files API and the Agent SDK's hosted features are Anthropic services, not part of the Messages format.

If your application depends on one of these, keep that part on Claude and move the rest. Many teams start with the requests that use none of them: classification, extraction, summaries, support answers.

Thinking, max_tokens and the bill

Recent Claude models think adaptively by default, and the thinking is returned as thinking blocks. Open reasoning models also think before they answer, on their own, without a parameter. Their reasoning is billed as output tokens, like Claude's, but it is not returned as thinking blocks: a block without a valid Anthropic signature would not be honest. In a stream, long reasoning keeps the connection alive with ping events, so the client does not take a long pause for a dead connection.

Two consequences. First, raise max_tokens. A limit sized for Claude's answers can be used up by the reasoning before the model writes the answer, and the response then ends with stop_reason: "max_tokens" and little or no text.

Second, expect a different token count. On the same 42 exercises of our Code Bench, reasoning included, Kimi K3.1 Pro wrote 4.5 times as many as Claude Opus 5.5, DeepSeek V4.1 Flash 5.7 times as many as Claude Sonnet 5.5, and GLM-5.3 1.2 times as many as Sonnet. The price per token is lower, but the bill depends on both numbers. Our measured comparison with Claude gives the cost of the same run on each model, and the savings calculator applies the measured ratio when both models have been measured.

Prompts and tools

A prompt written for Claude usually works on a strong open model, but not always in the same way. Instructions that Claude follows closely may be followed more loosely, or the other way round. Formatting habits differ: one model writes Markdown where another writes plain text. Long system prompts and XML-style tags are understood by the large models we serve, but test them rather than assume.

Three things are worth checking. If your code ends the conversation with a partial assistant message to steer the answer, that message is passed on as is, and whether the model continues it depends on the model. If your tools rely on Claude choosing the right tool among many, check the open model's choices on real cases. And if you parse the answer, check that the format holds over a few hundred requests, not one.

Tool calling matters most for agents. Pick a model whose tool calling we have measured: the integrations page shows, for each model in the catalogue, whether tool calls worked when we tested it.

Claude Code

Claude Code talks to models through the same Messages format, so it can run on an open model through the same endpoint. Set ANTHROPIC_BASE_URL to https://getfrontiereai.eu/api and ANTHROPIC_AUTH_TOKEN to your Frontière AI key, in your user settings rather than a project file you commit. Then map every model slot: ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL, which runs background tasks. A slot left unmapped asks for a Claude model, which we do not serve, and the call fails with a message naming the variable to set.

Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's real window, because Claude Code assumes 200,000 tokens for a model id it does not know. Features that run on Anthropic's servers do not work through a gateway: the web search tool, Remote Control, claude.ai connectors and voice dictation. Anthropic's documentation says it does not support using Claude Code with non-Claude models through a gateway. It works because the format is translated faithfully, but it is not a setup Anthropic supports. The Claude Code guide has the full settings block and the date we last tested it.

Move traffic in steps

Switching the base URL is quick; trusting the answers takes a test. A rollout that works:

  1. Replay a sample. Take a few hundred real requests, with their system prompts and tools, and send them to the open model. Read the answers, and keep the usage each call returns.
  2. Compare what matters to you. Accuracy on your cases, format, tool choices, length, and the tokens billed. A side-by-side read by someone who knows the domain catches more than a single score.
  3. Move one kind of request. Route the simplest category to the open model, keep the rest on Claude, and watch the error rate and the bill for a few weeks.
  4. Keep a way back. The model id and base URL are configuration. Keep them out of the code so you can switch back without a release.

The reason to move is often not the bill. Anthropic is a US company; the EU-sovereign models on Frontière AI are served in Europe by European providers named on each model page, which keeps them outside the direct reach of the US CLOUD Act. The sovereignty page explains how we draw that line.

FAQ

Do I have to rewrite my Anthropic SDK code?

No. Change the base URL to https://getfrontiereai.eu/api, use a Frontière AI key and change the model id. The request and response formats stay Anthropic's, including tool use and streaming.

Does prompt caching still work?

The cache_control markers are ignored, but the providers cache repeated prompt prefixes on their own. Tokens read from the cache are reported in cache_read_input_tokens, as with Anthropic.

Can I see the open model's reasoning?

Not as thinking blocks: they would have no valid Anthropic signature. The reasoning is billed as output tokens and counted in output_tokens, so the usage you read is the usage you pay for.

Why did my response stop with max_tokens and no text?

The model probably spent the limit on reasoning before writing the answer. Raise max_tokens: open reasoning models can write several times more tokens than Claude for the same task.

Is using Claude Code with an open model supported by Anthropic?

No. Anthropic's documentation says it does not support Claude Code with non-Claude models through a gateway. It works through our endpoint, with the limits listed in the Claude Code guide.

Loïc Jané

Founder of Frontière AI

Founder of Frontière AI, an API gateway to open-weight AI models published by FLEECE AI SASU in Chamalières, France. Articles on this blog are written from our own measurements and from the sources linked in the text, dated on the day they were checked.

Ready to try it?

Create an account and call any model in the catalog in minutes.

Create an account