From 0aae1bc8deb3a686251ec7a921d2cd890bf13154 Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Wed, 27 May 2026 11:14:36 +0800 Subject: [PATCH] fix(examples): use model alias in examples --- examples/images.py | 2 +- examples/mcp_tool_runner.py | 2 +- examples/messages.py | 4 ++-- examples/messages_stream.py | 2 +- examples/text_completions_demo_async.py | 2 +- examples/text_completions_demo_sync.py | 2 +- examples/text_completions_streaming.py | 4 ++-- examples/thinking.py | 2 +- examples/thinking_stream.py | 2 +- examples/tools.py | 4 ++-- examples/tools_runner_search_tool.py | 2 +- examples/tools_stream.py | 2 +- examples/web_search.py | 2 +- examples/web_search_stream.py | 2 +- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/images.py b/examples/images.py index 3a27afe86..7c0de7828 100644 --- a/examples/images.py +++ b/examples/images.py @@ -25,6 +25,6 @@ ], }, ], - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", ) print(response.model_dump_json(indent=2)) diff --git a/examples/mcp_tool_runner.py b/examples/mcp_tool_runner.py index 4d70d4e39..1e343977a 100644 --- a/examples/mcp_tool_runner.py +++ b/examples/mcp_tool_runner.py @@ -42,7 +42,7 @@ async def main() -> None: # Run a conversation with tool_runner() runner = client.beta.messages.tool_runner( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=1024, tools=tools, messages=[{"role": "user", "content": "List the files in /tmp"}], diff --git a/examples/messages.py b/examples/messages.py index aebfcd15d..b93eae2f3 100644 --- a/examples/messages.py +++ b/examples/messages.py @@ -10,7 +10,7 @@ "content": "Hello!", } ], - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", ) print(response) @@ -30,6 +30,6 @@ "content": "How are you?", }, ], - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", ) print(response2) diff --git a/examples/messages_stream.py b/examples/messages_stream.py index 19260b075..f569e4c18 100755 --- a/examples/messages_stream.py +++ b/examples/messages_stream.py @@ -16,7 +16,7 @@ async def main() -> None: "content": "Say hello there!", } ], - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", ) as stream: async for event in stream: if event.type == "text": diff --git a/examples/text_completions_demo_async.py b/examples/text_completions_demo_async.py index 00bc593d9..af76bf6b2 100644 --- a/examples/text_completions_demo_async.py +++ b/examples/text_completions_demo_async.py @@ -10,7 +10,7 @@ async def main() -> None: client = AsyncAnthropic() res = await client.completions.create( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", prompt=f"{anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? {anthropic.AI_PROMPT}", max_tokens_to_sample=1000, ) diff --git a/examples/text_completions_demo_sync.py b/examples/text_completions_demo_sync.py index 63ca8b59b..df6080b69 100644 --- a/examples/text_completions_demo_sync.py +++ b/examples/text_completions_demo_sync.py @@ -8,7 +8,7 @@ def main() -> None: client = Anthropic() res = client.completions.create( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", prompt=f"{anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? {anthropic.AI_PROMPT}", max_tokens_to_sample=1000, ) diff --git a/examples/text_completions_streaming.py b/examples/text_completions_streaming.py index 7b897fcc2..8ae700373 100644 --- a/examples/text_completions_streaming.py +++ b/examples/text_completions_streaming.py @@ -15,7 +15,7 @@ def sync_stream() -> None: stream = client.completions.create( prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}", - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", stream=True, max_tokens_to_sample=300, ) @@ -29,7 +29,7 @@ def sync_stream() -> None: async def async_stream() -> None: stream = await async_client.completions.create( prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}", - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", stream=True, max_tokens_to_sample=300, ) diff --git a/examples/thinking.py b/examples/thinking.py index ee622e16b..e512eb89a 100644 --- a/examples/thinking.py +++ b/examples/thinking.py @@ -3,7 +3,7 @@ client = anthropic.Anthropic() response = client.messages.create( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=3200, thinking={"type": "enabled", "budget_tokens": 1600}, messages=[{"role": "user", "content": "Create a haiku about Anthropic."}], diff --git a/examples/thinking_stream.py b/examples/thinking_stream.py index 3efb52bac..878a9ff50 100644 --- a/examples/thinking_stream.py +++ b/examples/thinking_stream.py @@ -3,7 +3,7 @@ client = anthropic.Anthropic() with client.messages.stream( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=3200, thinking={"type": "enabled", "budget_tokens": 1600}, messages=[{"role": "user", "content": "Create a haiku about Anthropic."}], diff --git a/examples/tools.py b/examples/tools.py index bd254c460..90093622a 100644 --- a/examples/tools.py +++ b/examples/tools.py @@ -21,7 +21,7 @@ ] message = client.messages.create( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=1024, messages=[user_message], tools=tools, @@ -32,7 +32,7 @@ tool = next(c for c in message.content if c.type == "tool_use") response = client.messages.create( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=1024, messages=[ user_message, diff --git a/examples/tools_runner_search_tool.py b/examples/tools_runner_search_tool.py index 48cbc4970..32fad6a50 100644 --- a/examples/tools_runner_search_tool.py +++ b/examples/tools_runner_search_tool.py @@ -68,7 +68,7 @@ def main() -> None: ] runner = client.beta.messages.tool_runner( max_tokens=1024, - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", tools=[*tools, make_tool_searcher(tools)], messages=[{"role": "user", "content": "What is the weather in SF?"}], betas=["tool-search-tool-2025-10-19"], diff --git a/examples/tools_stream.py b/examples/tools_stream.py index a69837f9c..a44ff4cce 100644 --- a/examples/tools_stream.py +++ b/examples/tools_stream.py @@ -8,7 +8,7 @@ async def main() -> None: async with client.messages.stream( max_tokens=1024, - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", tools=[ { "name": "get_weather", diff --git a/examples/web_search.py b/examples/web_search.py index 3363c6d89..005ad9754 100644 --- a/examples/web_search.py +++ b/examples/web_search.py @@ -6,7 +6,7 @@ # Create a message with web search enabled message = client.messages.create( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=1024, messages=[{"role": "user", "content": "What's the weather in New York?"}], tools=[ diff --git a/examples/web_search_stream.py b/examples/web_search_stream.py index 4d17e80c2..dfe47f28b 100644 --- a/examples/web_search_stream.py +++ b/examples/web_search_stream.py @@ -11,7 +11,7 @@ async def main() -> None: # Create an async stream with web search enabled async with client.beta.messages.stream( - model="claude-sonnet-4-5-20250929", + model="claude-sonnet-4-5", max_tokens=1024, messages=[{"role": "user", "content": "What's the weather in New York?"}], tools=[