From Anthropic to FlowModels.
FlowModels speaks the OpenAI format, so you call Claude models with the OpenAI SDK: messages, tools and response fields look different from the Anthropic SDK.
What changes
The base URL, the key and the model name. Everything else stays, as long as you do not use any of the fields in the table below.
| Setting | Before | On FlowModels |
|---|---|---|
| SDK | anthropic |
openai |
| Base URL | https://api.anthropic.com |
https://api.flowmodels.one/v1 |
| Key | ANTHROPIC_API_KEY |
FLOWMODELS_API_KEY |
| Model name | claude-sonnet-5-5 |
anthropic/claude-sonnet-5-5 |
The code before and after
- import anthropic
- client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
+ from openai import OpenAI
+ client = OpenAI(
+ base_url="https://api.flowmodels.one/v1",
+ api_key=os.environ["FLOWMODELS_API_KEY"],
+ )
- message = client.messages.create(
- model="claude-sonnet-5-5",
- max_tokens=1024,
- system="Keep your answers short.",
- messages=[{"role": "user", "content": "Hello!"}],
- )
- print(message.content[0].text)
+ response = client.chat.completions.create(
+ model="anthropic/claude-sonnet-5-5",
+ max_tokens=1024,
+ messages=[
+ {"role": "system", "content": "Keep your answers short."},
+ {"role": "user", "content": "Hello!"},
+ ],
+ )
+ print(response.choices[0].message.content)
Fields that behave differently
What the chosen model supports decides. The fields it accepts are listed under supported_parameters in GET /v1/models.
| Field | Behavior on FlowModels |
|---|---|
system |
Becomes a message with role: "system". |
max_tokens |
Still possible, but not required. Without a value the maximum of the model applies, and the highest possible amount is reserved before the call. |
stop_sequences |
Is called stop here. |
tools (input_schema) |
Is called tools[].function.parameters here, each entry with type: "function". |
tool_choice |
auto, none, required or {"type":"function","function":{"name":"…"}}. |
tool_use, tool_result |
Are called tool_calls on the response and role: "tool" with tool_call_id in the follow-up message. |
thinking |
Through reasoning_effort. The levels a model knows are listed under capabilities.reasoning_levels. |
response_format |
Anthropic models report no JSON shape. The API answers with 400 unsupported_for_model instead of quietly returning plain text. |
Image blocks |
Content of type image becomes an image_url block, only in messages with role: "user". |
Streaming |
Instead of content_block_delta, events arrive in chunk format, and you read the text from choices[0].delta.content. |
What to check after the move
-
The new key is in
FLOWMODELS_API_KEY, andGET /v1/modelslists your model. -
A call without streaming returns
choices[0].message.contentas expected. -
With
stream: truethe events arrive; withstream_options.include_usagethe usage is in the last event. -
Tool calls and
response_formatwork with exactly the model you use. -
Your error handling separates
429 insufficient_quota(credit exhausted) from429 rate_limit_exceeded,429 concurrent_requests_exceededand503 provider_overloaded. - The request log in your dashboard shows the model, tokens and cost of the call.
-
Your code reads the response from
choices[0].message.contentinstead ofcontent[0].text.