Skip to content

Commit c1bbb56

Browse files
feat: Add Horizon Alpha model from OpenRouter to CAMEL (#2972)
Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com> Co-authored-by: Wendong-Fan <w3ndong.fan@gmail.com>
1 parent a424a75 commit c1bbb56

File tree

4 files changed

+127
-1
lines changed

4 files changed

+127
-1
lines changed

camel/types/enums.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class ModelType(UnifiedModelType, Enum):
9191
OPENROUTER_LLAMA_4_SCOUT = "meta-llama/llama-4-scout"
9292
OPENROUTER_LLAMA_4_SCOUT_FREE = "meta-llama/llama-4-scout:free"
9393
OPENROUTER_OLYMPICODER_7B = "open-r1/olympiccoder-7b:free"
94+
OPENROUTER_HORIZON_ALPHA = "openrouter/horizon-alpha"
9495

9596
# LMStudio models
9697
LMSTUDIO_GEMMA_3_1B = "gemma-3-1b"
@@ -603,6 +604,7 @@ def is_openrouter(self) -> bool:
603604
ModelType.OPENROUTER_LLAMA_4_SCOUT,
604605
ModelType.OPENROUTER_LLAMA_4_SCOUT_FREE,
605606
ModelType.OPENROUTER_OLYMPICODER_7B,
607+
ModelType.OPENROUTER_HORIZON_ALPHA,
606608
}
607609

608610
@property
@@ -1276,6 +1278,7 @@ def token_limit(self) -> int:
12761278
elif self in {
12771279
ModelType.MISTRAL_CODESTRAL_MAMBA,
12781280
ModelType.OPENROUTER_LLAMA_4_MAVERICK_FREE,
1281+
ModelType.OPENROUTER_HORIZON_ALPHA,
12791282
}:
12801283
return 256_000
12811284

docs/mintlify/key_modules/models.mdx

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ Integrate your favorite models into CAMEL-AI with straightforward Python calls.
197197

198198
<Tab title="Qwen">
199199

200+
Leverage [Qwen](https://qwenlm.github.io/)'s state-of-the-art models for coding and reasoning:
201+
200202
```python
201203
from camel.models import ModelFactory
202204
from camel.types import ModelPlatformType, ModelType
@@ -214,11 +216,82 @@ Integrate your favorite models into CAMEL-AI with straightforward Python calls.
214216
print(response.msgs[0].content)
215217
```
216218

219+
</Tab>
220+
221+
<Tab title="OpenRouter">
222+
Access a wide variety of models through [OpenRouter](https://openrouter.ai/)'s unified API:
223+
224+
**Setup:** Set your OpenRouter API key as an environment variable:
225+
```bash
226+
export OPENROUTER_API_KEY="your-api-key-here"
227+
```
228+
229+
```python
230+
from camel.models import ModelFactory
231+
from camel.types import ModelPlatformType, ModelType
232+
from camel.configs import OpenRouterConfig
233+
from camel.agents import ChatAgent
234+
235+
# Using predefined OpenRouter models
236+
model = ModelFactory.create(
237+
model_platform=ModelPlatformType.OPENROUTER,
238+
model_type=ModelType.OPENROUTER_LLAMA_3_1_70B,
239+
model_config_dict=OpenRouterConfig(temperature=0.2).as_dict(),
240+
)
241+
242+
agent = ChatAgent(
243+
system_message="You are a helpful assistant.",
244+
model=model
245+
)
246+
247+
response = agent.step("Say hi to CAMEL AI community.")
248+
print(response.msgs[0].content)
249+
```
250+
251+
<Note type="info">
252+
CAMEL supports several predefined OpenRouter models including:
253+
- `OPENROUTER_LLAMA_3_1_405B` - Meta's Llama 3.1 405B model
254+
- `OPENROUTER_LLAMA_3_1_70B` - Meta's Llama 3.1 70B model
255+
- `OPENROUTER_LLAMA_4_MAVERICK` - Meta's Llama 4 Maverick model
256+
- `OPENROUTER_LLAMA_4_SCOUT` - Meta's Llama 4 Scout model
257+
- `OPENROUTER_OLYMPICODER_7B` - Open R1's OlympicCoder 7B model
258+
- `OPENROUTER_HORIZON_ALPHA` - Horizon Alpha model
259+
260+
Free versions are also available for some models (e.g., `OPENROUTER_LLAMA_4_MAVERICK_FREE`).
261+
</Note>
262+
263+
You can also use any OpenRouter model via the OpenAI-compatible interface:
264+
265+
```python
266+
import os
267+
from camel.models import ModelFactory
268+
from camel.types import ModelPlatformType
269+
270+
# Use any model available on OpenRouter
271+
model = ModelFactory.create(
272+
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
273+
model_type="anthropic/claude-3.5-sonnet", # Any OpenRouter model
274+
url="https://openrouter.ai/api/v1",
275+
api_key=os.getenv("OPENROUTER_API_KEY"),
276+
model_config_dict={"temperature": 0.2},
277+
)
278+
279+
agent = ChatAgent(
280+
system_message="You are a helpful assistant.",
281+
model=model
282+
)
283+
284+
response = agent.step("Explain quantum computing in simple terms.")
285+
print(response.msgs[0].content)
286+
```
287+
288+
**Available Models:** View the full list of models available through OpenRouter at [openrouter.ai/models](https://openrouter.ai/models).
289+
217290
</Tab>
218291

219292
<Tab title="Groq">
220293

221-
Using Groq's powerful models (e.g., Llama 3.3-70B):
294+
Using [Groq](https://groq.com/)'s powerful models (e.g., Llama 3.3-70B):
222295

223296
```python
224297
from camel.models import ModelFactory
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14+
15+
from camel.agents import ChatAgent
16+
from camel.configs import OpenRouterConfig
17+
from camel.models import ModelFactory
18+
from camel.types import ModelPlatformType, ModelType
19+
20+
# Create Horizon Alpha model
21+
model = ModelFactory.create(
22+
model_platform=ModelPlatformType.OPENROUTER,
23+
model_type=ModelType.OPENROUTER_HORIZON_ALPHA,
24+
model_config_dict=OpenRouterConfig(temperature=0.7).as_dict(),
25+
)
26+
27+
# Define system message
28+
sys_msg = "You are a helpful AI assistant powered by Horizon Alpha model."
29+
30+
# Set agent
31+
camel_agent = ChatAgent(system_message=sys_msg, model=model)
32+
33+
user_msg = """Tell me about your capabilities and what makes you unique
34+
as the Horizon Alpha model."""
35+
36+
# Get response information
37+
response = camel_agent.step(user_msg)
38+
print(response.msgs[0].content)
39+
40+
'''
41+
===============================================================================
42+
This example demonstrates how to use the Horizon Alpha model from OpenRouter
43+
with CAMEL AI framework. The Horizon Alpha model is a cloaked model provided
44+
for community feedback with 256,000 context tokens support.
45+
46+
Note: During the testing period, this model is free to use. Make sure to set
47+
your OPENROUTER_API_KEY environment variable before running this example.
48+
===============================================================================
49+
'''

test/models/test_openrouter_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
ModelType.OPENROUTER_LLAMA_3_1_405B,
2929
ModelType.OPENROUTER_LLAMA_3_1_70B,
3030
ModelType.OPENROUTER_OLYMPICODER_7B,
31+
ModelType.OPENROUTER_HORIZON_ALPHA,
3132
],
3233
)
3334
def test_openrouter_model(model_type: ModelType):

0 commit comments

Comments
 (0)