🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
feat(models): Add Claude Sonnet 4.5 support (#3229)
Sarthak Bhardwaj56b40d1b0374
diff --git a/camel/types/enums.py b/camel/types/enums.pyindex a3967618b..e407d1d00 100644--- a/camel/types/enums.py+++ b/camel/types/enums.py@@ -207,6 +207,7 @@ class ModelType(UnifiedModelType, Enum):CLAUDE_3_5_SONNET = "claude-3-5-sonnet-latest"CLAUDE_3_5_HAIKU = "claude-3-5-haiku-latest"CLAUDE_3_7_SONNET = "claude-3-7-sonnet-latest"+ CLAUDE_4_5_SONNET = "claude-4-5-sonnet-latest"CLAUDE_SONNET_4 = "claude-sonnet-4-20250514"CLAUDE_OPUS_4 = "claude-opus-4-20250514"CLAUDE_OPUS_4_1 = "claude-opus-4-1-20250805"@@ -641,6 +642,7 @@ class ModelType(UnifiedModelType, Enum):ModelType.CLAUDE_3_5_SONNET,ModelType.CLAUDE_3_5_HAIKU,ModelType.CLAUDE_3_7_SONNET,+ ModelType.CLAUDE_4_5_SONNET,ModelType.CLAUDE_SONNET_4,ModelType.CLAUDE_OPUS_4,ModelType.CLAUDE_OPUS_4_1,@@ -1421,6 +1423,7 @@ class ModelType(UnifiedModelType, Enum):ModelType.CLAUDE_3_5_SONNET,ModelType.CLAUDE_3_5_HAIKU,ModelType.CLAUDE_3_7_SONNET,+ ModelType.CLAUDE_4_5_SONNET,ModelType.CLAUDE_SONNET_4,ModelType.CLAUDE_OPUS_4,ModelType.CLAUDE_OPUS_4_1,diff --git a/docs/mintlify/key_modules/models.mdx b/docs/mintlify/key_modules/models.mdxindex 83ed5656d..1a223fd66 100644--- a/docs/mintlify/key_modules/models.mdx+++ b/docs/mintlify/key_modules/models.mdx@@ -40,7 +40,7 @@ CAMEL supports a wide range of models, including [OpenAI’s GPT series](https:/| **Azure OpenAI** | gpt-4o, gpt-4-turbo<br/>gpt-4, gpt-3.5-turbo || **Mistral AI** | mistral-large-latest, pixtral-12b-2409<br/>ministral-8b-latest, ministral-3b-latest<br/>open-mistral-nemo, codestral-latest<br/>open-mistral-7b, open-mixtral-8x7b<br/>open-mixtral-8x22b, open-codestral-mamba<br/>mistral-small-2506, mistral-medium-2508<br/>magistral-small-1.2, magistral-medium-1.2 || **Moonshot** | moonshot-v1-8k<br/>moonshot-v1-32k<br/>moonshot-v1-128k |-| **Anthropic** | claude-2.1, claude-2.0, claude-instant-1.2<br/>claude-3-opus-latest, claude-3-sonnet-20240229, claude-3-haiku-20240307<br/>claude-3-5-sonnet-latest, claude-3-5-haiku-latest |+| **Anthropic** | claude-2.1, claude-2.0, claude-instant-1.2<br/>claude-3-opus-latest, claude-3-sonnet-20240229, claude-3-haiku-20240307<br/>claude-3-5-sonnet-latest, claude-3-5-haiku-latest, claude-3-7-sonnet-latest<br/>claude-4-5-sonnet-latest, claude-sonnet-4-20250514, claude-opus-4-20250514, claude-opus-4-1-20250805 || **Gemini** | gemini-2.5-pro, gemini-2.5-flash<br/>gemini-2.0-flash, gemini-2.0-flash-thinking<br/> gemini-2.0-flash-lite|| **Lingyiwanwu** | yi-lightning, yi-large, yi-medium<br/>yi-large-turbo, yi-vision, yi-medium-200k<br/>yi-spark, yi-large-rag, yi-large-fc || **Qwen** | qwen3-coder-plus,qwq-32b-preview, qwen-max, qwen-plus, qwen-turbo, qwen-long<br/>qwen-vl-max, qwen-vl-plus, qwen-math-plus, qwen-math-turbo, qwen-coder-turbo<br/>qwen2.5-coder-32b-instruct, qwen2.5-72b-instruct, qwen2.5-32b-instruct, qwen2.5-14b-instruct |diff --git a/examples/models/claude_4_5_sonnet_example.py b/examples/models/claude_4_5_sonnet_example.pynew file mode 100644index 000000000..d43dec577--- /dev/null+++ b/examples/models/claude_4_5_sonnet_example.py@@ -0,0 +1,110 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++from camel.agents import ChatAgent+from camel.configs import AnthropicConfig+from camel.models import ModelFactory+from camel.toolkits import FunctionTool+from camel.types import ModelPlatformType, ModelType++"""+Claude Sonnet 4.5 Example++Please set the environment variable:+export ANTHROPIC_API_KEY="your-api-key-here"+"""++print("Testing Claude Sonnet 4.5 Integration...")++# Create Claude Sonnet 4.5 model+model = ModelFactory.create(+ model_platform=ModelPlatformType.ANTHROPIC,+ model_type=ModelType.CLAUDE_4_5_SONNET,+ model_config_dict=AnthropicConfig(temperature=0.2).as_dict(),+)++# Define system message+sys_msg = "You are a helpful AI assistant powered by Claude Sonnet 4.5."++# Set agent+camel_agent = ChatAgent(system_message=sys_msg, model=model)++print(f"Model Type: {model.model_type}")+print(f"Model Platform: {ModelPlatformType.ANTHROPIC}")+print(f"Is Anthropic: {model.model_type.is_anthropic}")+print(f"Token Limit: {model.model_type.token_limit}")++# Test basic conversation+user_msg = """Hello Claude Sonnet 4.5! Can you tell me about your \+capabilities and how you differ from previous versions?"""++print(f"\nUser: {user_msg}")+print("Assistant:", end=" ")++try:+ response = camel_agent.step(user_msg)+ print(response.msgs[0].content)+ print("\n✅ Basic conversation test PASSED")+except Exception as e:+ print(f"\n❌ Basic conversation test FAILED: {e}")+++# Test with tool calling+def calculate_circle_area(radius: float) -> float:+ """Calculate the area of a circle given its radius."""+ import math++ return math.pi * radius * radius+++# Create agent with tools+tool_agent = ChatAgent(+ system_message=sys_msg,+ model=model,+ tools=[FunctionTool(calculate_circle_area)],+)++print("\n" + "=" * 50)+print("Testing Claude Sonnet 4.5 with tool calling:")++user_msg = (+ "Please use the calculate_circle_area tool to find the area "+ "of a circle with radius 5."+)++print(f"\nUser: {user_msg}")+print("Assistant:", end=" ")++try:+ response = tool_agent.step(user_msg)+ print(response.msgs[0].content)++ # Check if tool was called+ if response.info and response.info.get("tool_calls"):+ print("\n✅ Tool calling test PASSED")+ print(f"Tool calls: {response.info['tool_calls']}")+ else:+ print(+ "\n⚠️ Tool calling may not have been used (expected for this test)"+ )++except Exception as e:+ print(f"\n❌ Tool calling test FAILED: {e}")++print("\n" + "=" * 50)+print("Claude Sonnet 4.5 integration test completed!")+print(+ "If you see this message without errors, "+ "the integration is working correctly."+)diff --git a/test/models/test_anthropic_model.py b/test/models/test_anthropic_model.pyindex 5db91e97d..a8134dc15 100644--- a/test/models/test_anthropic_model.py+++ b/test/models/test_anthropic_model.py@@ -32,6 +32,11 @@ from camel.utils import OpenAITokenCounterModelType.CLAUDE_3_HAIKU,ModelType.CLAUDE_3_5_SONNET,ModelType.CLAUDE_3_5_HAIKU,+ ModelType.CLAUDE_3_7_SONNET,+ ModelType.CLAUDE_4_5_SONNET,+ ModelType.CLAUDE_SONNET_4,+ ModelType.CLAUDE_OPUS_4,+ ModelType.CLAUDE_OPUS_4_1,],)def test_anthropic_model(model_type: ModelType):