Skip to content
Nilay Kabariya

Entry No.087·AI··4 min read

Claude SDK: unexpected keyword argument temperature, betas

Messages.create() got an unexpected keyword argument after an anthropic upgrade, plus what SDK 2.0 (October 21) breaks next. Python and TypeScript, tested.

by Nilay#anthropic#claude#python#nodeAI

The error, verbatim

Jump to the fix ↓
TypeError: Messages.create() got an unexpected keyword argument 'temperature'
✓ Reproduced on Windows 11 Pro

Tested on

anthropic (Python)
0.125.0, 1.0.0 to 1.17.0, 2.1.0
@anthropic-ai/sdk
0.137.0 and 1.1.0
Runtime
Python 3.14.5, Node 24.14.0, TypeScript 5
OS
Windows 11 Pro
Contents
  1. ‘temperature’, ‘top_p’ or ‘top_k’01
  2. ‘betas’02
  3. TypeScript: no error at runtime03
  4. What SDK 2.0 changes on top (October 21, 2026)04
  5. How this was tested05

This TypeError comes from Python, not from Claude. The anthropic package checks your arguments before it sends anything, and a name that messages.create() no longer has stops the call right there. No request goes out, so the model you picked makes no difference.

I ran the same calls on eight versions of the Python SDK and two of the TypeScript one. In Python, the cut wasn’t at the new 2.0 release:

messages.create(...) with 0.125.0 1.0.0 to 1.17.0 2.1.0
temperature=0.2 sent TypeError TypeError
top_p=0.9 or top_k=5 sent TypeError TypeError
betas=[...] TypeError TypeError TypeError

messages.stream() and messages.count_tokens() raised the same TypeError for temperature. If your code with temperature worked before, the upgrade that broke it was to 1.0 or later. betas failed on every version, because it never belonged there.

‘temperature’, ‘top_p’ or ‘top_k’

The three sampling parameters are gone from the SDK. Newer Claude models accept only their default values anyway, and the API is heading the same way (more on that below).

Delete the argument:

client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
    # temperature=0.2,   <- delete
)

The request then samples with the default, a temperature of 1.0. On models that accept other values, such as Claude Sonnet 4.6, a lower temperature for steadier output is lost, and nothing in the SDK replaces it.

If an older model still needs the value, extra_body sends it anyway:

client.messages.create(..., extra_body={"temperature": 0.2})

That worked on 1.17.0 and 2.1.0: the request body had "temperature": 0.2 in it. It’s only a bridge, though. On 2.x it collides with the new API version, covered further down.

‘betas’

betas was never an argument of client.messages.create(), on any version I tried. It turns on beta features through a request header, and the plain messages methods don’t send that header.

Call the same method through client.beta:

client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
    betas=["context-1m-2025-08-07"],
)

The beta method doesn’t take temperature either from 1.0 on: it raised the same TypeError on 1.17.0 and 2.1.0, while 0.125.0 still sent it.

TypeScript: no error at runtime

The TypeScript SDK behaves differently. In 1.1.0, temperature is gone from the types, so tsc stops:

error TS2769: No overload matches this call.
  Object literal may only specify known properties, and 'temperature' does not exist in type 'MessageCreateParamsNonStreaming'.

But from plain JavaScript, or past a type cast, 1.1.0 still put "temperature": 0.2 in the request. So a JavaScript project gets no local error at all, and the request goes to the API with the parameter.

What SDK 2.0 changes on top (October 21, 2026)

On October 21, Anthropic released API version 2026-10-21 with new major SDKs: anthropic 2.0.0 for Python and @anthropic-ai/sdk 1.0.0 for TypeScript. I compared 1.17.0 with 2.1.0, and 0.137.0 with 1.1.0, against a local server that recorded every request:

What I checked Python 1.17.0 / TS 0.137.0 Python 2.1.0 / TS 1.1.0
anthropic-version header 2023-06-01 2026-10-21
Header with the API key X-Api-Key: sk-ant-... Authorization: Bearer sk-ant-...
Both api_key and auth_token sent both ValueError / TypeError
MessageParam(role="user", content="hi") returned a dict TypeError: 'typing.Union' object is not callable
client.completions (TypeScript) worked Cannot read properties of undefined (reading 'create')

Python 1.17.0 already had no client.completions: AttributeError: 'Anthropic' object has no attribute 'completions'.

temperature through extra_body now fails at the API

Anthropic’s migration guide says a 2026-10-21 request that sends temperature, top_p or top_k gets a 400 error, “even at the parameter’s default value”, on every model. Since 2.x sends that version, the extra_body bridge and the TypeScript runtime case above both send the parameter where the API now rejects it. I couldn’t confirm the 400 myself: without a paid key, the API answers every request with invalid x-api-key before it reads the body.

If a request truly needs a non-default temperature on an older model, keep that one request on the old API version:

client.messages.create(
    ...,
    extra_body={"temperature": 0.2},
    extra_headers={"anthropic-version": "2023-06-01"},
)

Otherwise, delete the parameter. That’s the version Anthropic says to use from now on.

Your proxy stopped seeing the key

If you run a gateway or proxy that reads X-Api-Key, it gets nothing from 2.x, because the key now travels in Authorization. The API itself accepts either header.

Change the proxy to read Authorization: Bearer. If you can’t yet, send the key in the old header yourself:

client = anthropic.Anthropic(default_headers={"X-Api-Key": key})

ValueError: Pass at most one of api_key=, auth_token=

ValueError: Pass at most one of `api_key=`, `auth_token=`, `credentials=`, `config=`, or `profile=`. Received `api_key=`, `auth_token=`.

1.17.0 sent both credentials, each in its own header. 2.1.0 refuses. TypeScript 1.1.0 throws the same message as a TypeError, with apiKey and authToken. Pass one. If a gateway needs a token and the API behind it needs your key, pass the token as auth_token and the key as default_headers={"X-Api-Key": key}. That combination went through on 2.1.0 with both headers.

MessageParam is no longer callable

MessageParam is now a union of one type per role. Write the message as a dict and keep the name for annotations:

message: MessageParam = {"role": "user", "content": "Hello"}

How this was tested

Windows 11 Pro, Python 3.14.5 and Node 24.14.0, October 23, 2026. Each SDK version ran in its own venv or node_modules, pointed with base_url / baseURL at a local HTTP server that recorded headers and bodies and answered with a fixed message, so no real API calls were made. anthropic 0.125.0, 1.0.0, 1.8.0, 1.12.0, 1.14.0 and 1.16.0 were checked for which arguments messages.create() accepts; 1.17.0 and 2.1.0 ran every call above. The TypeScript cases were compiled with TypeScript 5 and run with tsx. The 400 from the API is from Anthropic’s migration guide, not my own test. The test scripts are public.

— N.K., end of entry No.087

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.060

    Claude "temperature is deprecated for this model" (400)

    Switching to Claude Sonnet 5.5, Haiku 5.5 or Opus 4.7 breaks code that sets temperature, even temperature: 0. Every case tested, in Node and Python.

    > BadRequestError: 400 {"type":"error","error":{"type":"invalid_request_error","message":"`temperature` is deprecated for this model."}}

    AI4 min
  2. No.088

    Responses.create() unexpected keyword argument: new names

    max_tokens, messages, response_format, seed: their names in OpenAI's Responses API, tested. Plus the 'proxies' TypeError from httpx 0.28.

    > TypeError: Responses.create() got an unexpected keyword argument 'max_tokens'

    AI6 min
  3. No.022

    Fix: Could not resolve authentication method (Anthropic / Claude SDK)

    Anthropic's SDK can't find your key. The old and new wording, ANTHROPIC_API_KEY vs ANTHROPIC_AUTH_TOKEN, and the 401 you get when a key is in the wrong one.

    > Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.

    AI4 min

Post card · Every Sunday

What broke this week.

One email on Sundays: the Node, TypeScript, Python and AI SDK releases that broke builds that week, each one reproduced, with a link to the fix that worked. Never shared, and you can leave any time.

— Nilay

or follow by RSSor on X

By subscribing you agree to the privacy note. One click to leave.

tip: paste the exact error text