Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

feat: Add Horizon Alpha model from OpenRouter to CAMEL (#2972)

Sarthak Bhardwajc1bbb56644dd
diff --git a/camel/types/enums.py b/camel/types/enums.py
index 36f06782e..dc51673c5 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -91,6 +91,7 @@ class ModelType(UnifiedModelType, Enum):
OPENROUTER_LLAMA_4_SCOUT = "meta-llama/llama-4-scout"
OPENROUTER_LLAMA_4_SCOUT_FREE = "meta-llama/llama-4-scout:free"
OPENROUTER_OLYMPICODER_7B = "open-r1/olympiccoder-7b:free"
+ OPENROUTER_HORIZON_ALPHA = "openrouter/horizon-alpha"
# LMStudio models
LMSTUDIO_GEMMA_3_1B = "gemma-3-1b"
@@ -603,6 +604,7 @@ class ModelType(UnifiedModelType, Enum):
ModelType.OPENROUTER_LLAMA_4_SCOUT,
ModelType.OPENROUTER_LLAMA_4_SCOUT_FREE,
ModelType.OPENROUTER_OLYMPICODER_7B,
+ ModelType.OPENROUTER_HORIZON_ALPHA,
}
@property
@@ -1276,6 +1278,7 @@ class ModelType(UnifiedModelType, Enum):
elif self in {
ModelType.MISTRAL_CODESTRAL_MAMBA,
ModelType.OPENROUTER_LLAMA_4_MAVERICK_FREE,
+ ModelType.OPENROUTER_HORIZON_ALPHA,
}:
return 256_000
diff --git a/docs/mintlify/key_modules/models.mdx b/docs/mintlify/key_modules/models.mdx
index 8c2a88a28..95f18133c 100644
--- a/docs/mintlify/key_modules/models.mdx
+++ b/docs/mintlify/key_modules/models.mdx
@@ -197,6 +197,8 @@ Integrate your favorite models into CAMEL-AI with straightforward Python calls.
<Tab title="Qwen">
+ Leverage [Qwen](https://qwenlm.github.io/)'s state-of-the-art models for coding and reasoning:
+
```python
from camel.models import ModelFactory
from camel.types import ModelPlatformType, ModelType
@@ -214,11 +216,82 @@ Integrate your favorite models into CAMEL-AI with straightforward Python calls.
print(response.msgs[0].content)
```
+ </Tab>
+
+ <Tab title="OpenRouter">
+ Access a wide variety of models through [OpenRouter](https://openrouter.ai/)'s unified API:
+
+ **Setup:** Set your OpenRouter API key as an environment variable:
+ ```bash
+ export OPENROUTER_API_KEY="your-api-key-here"
+ ```
+
+ ```python
+ from camel.models import ModelFactory
+ from camel.types import ModelPlatformType, ModelType
+ from camel.configs import OpenRouterConfig
+ from camel.agents import ChatAgent
+
+ # Using predefined OpenRouter models
+ model = ModelFactory.create(
+ model_platform=ModelPlatformType.OPENROUTER,
+ model_type=ModelType.OPENROUTER_LLAMA_3_1_70B,
+ model_config_dict=OpenRouterConfig(temperature=0.2).as_dict(),
+ )
+
+ agent = ChatAgent(
+ system_message="You are a helpful assistant.",
+ model=model
+ )
+
+ response = agent.step("Say hi to CAMEL AI community.")
+ print(response.msgs[0].content)
+ ```
+
+ <Note type="info">
+ CAMEL supports several predefined OpenRouter models including:
+ - `OPENROUTER_LLAMA_3_1_405B` - Meta's Llama 3.1 405B model
+ - `OPENROUTER_LLAMA_3_1_70B` - Meta's Llama 3.1 70B model
+ - `OPENROUTER_LLAMA_4_MAVERICK` - Meta's Llama 4 Maverick model
+ - `OPENROUTER_LLAMA_4_SCOUT` - Meta's Llama 4 Scout model
+ - `OPENROUTER_OLYMPICODER_7B` - Open R1's OlympicCoder 7B model
+ - `OPENROUTER_HORIZON_ALPHA` - Horizon Alpha model
+
+ Free versions are also available for some models (e.g., `OPENROUTER_LLAMA_4_MAVERICK_FREE`).
+ </Note>
+
+ You can also use any OpenRouter model via the OpenAI-compatible interface:
+
+ ```python
+ import os
+ from camel.models import ModelFactory
+ from camel.types import ModelPlatformType
+
+ # Use any model available on OpenRouter
+ model = ModelFactory.create(
+ model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
+ model_type="anthropic/claude-3.5-sonnet", # Any OpenRouter model
+ url="https://openrouter.ai/api/v1",
+ api_key=os.getenv("OPENROUTER_API_KEY"),
+ model_config_dict={"temperature": 0.2},
+ )
+
+ agent = ChatAgent(
+ system_message="You are a helpful assistant.",
+ model=model
+ )
+
+ response = agent.step("Explain quantum computing in simple terms.")
+ print(response.msgs[0].content)
+ ```
+
+ **Available Models:** View the full list of models available through OpenRouter at [openrouter.ai/models](https://openrouter.ai/models).
+
</Tab>
<Tab title="Groq">
- Using Groq's powerful models (e.g., Llama 3.3-70B):
+ Using [Groq](https://groq.com/)'s powerful models (e.g., Llama 3.3-70B):
```python
from camel.models import ModelFactory
diff --git a/examples/models/openrouter_horizon_alpha_example.py b/examples/models/openrouter_horizon_alpha_example.py
new file mode 100644
index 000000000..2f21884b8
--- /dev/null
+++ b/examples/models/openrouter_horizon_alpha_example.py
@@ -0,0 +1,49 @@
+# ========= 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 OpenRouterConfig
+from camel.models import ModelFactory
+from camel.types import ModelPlatformType, ModelType
+
+# Create Horizon Alpha model
+model = ModelFactory.create(
+ model_platform=ModelPlatformType.OPENROUTER,
+ model_type=ModelType.OPENROUTER_HORIZON_ALPHA,
+ model_config_dict=OpenRouterConfig(temperature=0.7).as_dict(),
+)
+
+# Define system message
+sys_msg = "You are a helpful AI assistant powered by Horizon Alpha model."
+
+# Set agent
+camel_agent = ChatAgent(system_message=sys_msg, model=model)
+
+user_msg = """Tell me about your capabilities and what makes you unique
+ as the Horizon Alpha model."""
+
+# Get response information
+response = camel_agent.step(user_msg)
+print(response.msgs[0].content)
+
+'''
+===============================================================================
+This example demonstrates how to use the Horizon Alpha model from OpenRouter
+with CAMEL AI framework. The Horizon Alpha model is a cloaked model provided
+for community feedback with 256,000 context tokens support.
+
+Note: During the testing period, this model is free to use. Make sure to set
+your OPENROUTER_API_KEY environment variable before running this example.
+===============================================================================
+'''
diff --git a/test/models/test_openrouter_model.py b/test/models/test_openrouter_model.py
index f2eb219b1..420c926e3 100644
--- a/test/models/test_openrouter_model.py
+++ b/test/models/test_openrouter_model.py
@@ -28,6 +28,7 @@ from camel.utils import OpenAITokenCounter
ModelType.OPENROUTER_LLAMA_3_1_405B,
ModelType.OPENROUTER_LLAMA_3_1_70B,
ModelType.OPENROUTER_OLYMPICODER_7B,
+ ModelType.OPENROUTER_HORIZON_ALPHA,
],
)
def test_openrouter_model(model_type: ModelType):