@@ -820,7 +820,7 @@ class Joke(BaseModel):
820820 image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
821821 image_data = base64.b64encode(httpx.get(image_url).content).decode("utf-8")
822822
823- model = ChatAnthropic(model="claude-3-5- sonnet-latest ")
823+ model = ChatAnthropic(model="claude-sonnet-4-5 ")
824824 message = HumanMessage(
825825 content=[
826826 {
@@ -887,7 +887,7 @@ class Joke(BaseModel):
887887 url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
888888 data = b64encode(requests.get(url).content).decode()
889889
890- model = ChatAnthropic(model="claude-3-5- sonnet-latest ")
890+ model = ChatAnthropic(model="claude-sonnet-4-5 ")
891891 ai_msg = model.invoke(
892892 [
893893 HumanMessage(
@@ -1948,7 +1948,7 @@ class GetPrice(BaseModel):
19481948 product: str = Field(..., description="The product to look up.")
19491949
19501950
1951- model = ChatAnthropic(model="claude-3-5- sonnet-latest ", temperature=0)
1951+ model = ChatAnthropic(model="claude-sonnet-4-5 ", temperature=0)
19521952 model_with_tools = model.bind_tools([GetWeather, GetPrice])
19531953 model_with_tools.invoke(
19541954 "What is the weather like in San Francisco",
@@ -1958,7 +1958,7 @@ class GetPrice(BaseModel):
19581958 # {'text': '<thinking>\nBased on the user\'s question, the relevant function to call is GetWeather, which requires the "location" parameter.\n\nThe user has directly specified the location as "San Francisco". Since San Francisco is a well known city, I can reasonably infer they mean San Francisco, CA without needing the state specified.\n\nAll the required parameters are provided, so I can proceed with the API call.\n</thinking>', 'type': 'text'},
19591959 # {'text': None, 'type': 'tool_use', 'id': 'toolu_01SCgExKzQ7eqSkMHfygvYuu', 'name': 'GetWeather', 'input': {'location': 'San Francisco, CA'}}
19601960 # ],
1961- # response_metadata={'id': 'msg_01GM3zQtoFv8jGQMW7abLnhi', 'model': 'claude-3-5- sonnet-latest ', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 487, 'output_tokens': 145}},
1961+ # response_metadata={'id': 'msg_01GM3zQtoFv8jGQMW7abLnhi', 'model': 'claude-sonnet-4-5 ', 'stop_reason': 'tool_use', 'stop_sequence': None, 'usage': {'input_tokens': 487, 'output_tokens': 145}},
19621962 # id='run-87b1331e-9251-4a68-acef-f0a018b639cc-0'
19631963 # )
19641964 ```
@@ -1982,7 +1982,7 @@ class GetPrice(BaseModel):
19821982 product: str = Field(..., description="The product to look up.")
19831983
19841984
1985- model = ChatAnthropic(model="claude-3-5- sonnet-latest ", temperature=0)
1985+ model = ChatAnthropic(model="claude-sonnet-4-5 ", temperature=0)
19861986 model_with_tools = model.bind_tools([GetWeather, GetPrice], tool_choice="any")
19871987 model_with_tools.invoke(
19881988 "what is the weather like in San Francisco",
@@ -2008,7 +2008,7 @@ class GetPrice(BaseModel):
20082008 product: str = Field(..., description="The product to look up.")
20092009
20102010
2011- model = ChatAnthropic(model="claude-3-5- sonnet-latest ", temperature=0)
2011+ model = ChatAnthropic(model="claude-sonnet-4-5 ", temperature=0)
20122012 model_with_tools = model.bind_tools([GetWeather, GetPrice], tool_choice="GetWeather")
20132013 model_with_tools.invoke("What is the weather like in San Francisco")
20142014 ```
@@ -2043,7 +2043,7 @@ class GetPrice(BaseModel):
20432043 # We need to pass in extra headers to enable use of the beta cache
20442044 # control API.
20452045 model = ChatAnthropic(
2046- model="claude-3-5- sonnet-latest ",
2046+ model="claude-sonnet-4-5 ",
20472047 temperature=0,
20482048 )
20492049 model_with_tools = model.bind_tools([GetWeather, cached_price_tool])
@@ -2068,7 +2068,7 @@ class GetPrice(BaseModel):
20682068 ],
20692069 response_metadata={
20702070 "id": "msg_01Xg7Wr5inFWgBxE5jH9rpRo",
2071- "model": "claude-3-5- sonnet-latest ",
2071+ "model": "claude-sonnet-4-5 ",
20722072 "stop_reason": "tool_use",
20732073 "stop_sequence": None,
20742074 "usage": {
@@ -2113,7 +2113,7 @@ class GetPrice(BaseModel):
21132113 ],
21142114 response_metadata={
21152115 "id": "msg_016RfWHrRvW6DAGCdwB6Ac64",
2116- "model": "claude-3-5- sonnet-latest ",
2116+ "model": "claude-sonnet-4-5 ",
21172117 "stop_reason": "tool_use",
21182118 "stop_sequence": None,
21192119 "usage": {
@@ -2240,7 +2240,7 @@ class AnswerWithJustification(BaseModel):
22402240 justification: str
22412241
22422242
2243- model = ChatAnthropic(model="claude-3-5- sonnet-latest ", temperature=0)
2243+ model = ChatAnthropic(model="claude-sonnet-4-5 ", temperature=0)
22442244 structured_model = model.with_structured_output(AnswerWithJustification)
22452245
22462246 structured_model.invoke("What weighs more a pound of bricks or a pound of feathers")
@@ -2265,7 +2265,7 @@ class AnswerWithJustification(BaseModel):
22652265 justification: str
22662266
22672267
2268- model = ChatAnthropic(model="claude-3-5- sonnet-latest ", temperature=0)
2268+ model = ChatAnthropic(model="claude-sonnet-4-5 ", temperature=0)
22692269 structured_model = model.with_structured_output(AnswerWithJustification, include_raw=True)
22702270
22712271 structured_model.invoke("What weighs more a pound of bricks or a pound of feathers")
@@ -2293,7 +2293,7 @@ class AnswerWithJustification(BaseModel):
22932293 "required": ["answer", "justification"],
22942294 },
22952295 }
2296- model = ChatAnthropic(model="claude-3-5- sonnet-latest ", temperature=0)
2296+ model = ChatAnthropic(model="claude-sonnet-4-5 ", temperature=0)
22972297 structured_model = model.with_structured_output(schema)
22982298
22992299 structured_model.invoke("What weighs more a pound of bricks or a pound of feathers")
@@ -2365,7 +2365,7 @@ def get_num_tokens_from_messages(
23652365 from langchain_anthropic import ChatAnthropic
23662366 from langchain_core.messages import HumanMessage, SystemMessage
23672367
2368- model = ChatAnthropic(model="claude-3-5-sonnet-20241022 ")
2368+ model = ChatAnthropic(model="claude-sonnet-4-5-20250929 ")
23692369
23702370 messages = [
23712371 SystemMessage(content="You are a scientist"),
@@ -2385,7 +2385,7 @@ def get_num_tokens_from_messages(
23852385 from langchain_core.messages import HumanMessage
23862386 from langchain_core.tools import tool
23872387
2388- model = ChatAnthropic(model="claude-3-5-sonnet-20241022 ")
2388+ model = ChatAnthropic(model="claude-sonnet-4-5-20250929 ")
23892389
23902390 @tool(parse_docstring=True)
23912391 def get_weather(location: str) -> str:
0 commit comments