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 Avian as a new LLM provider (#3881)

avianion735d3f873538
diff --git a/camel/configs/__init__.py b/camel/configs/__init__.py
index ceaf77520..9d329f282 100644
--- a/camel/configs/__init__.py
+++ b/camel/configs/__init__.py
@@ -16,6 +16,7 @@ from .aiml_config import AIML_API_PARAMS, AIMLConfig
from .amd_config import AMD_API_PARAMS, AMDConfig
from .anthropic_config import ANTHROPIC_API_PARAMS, AnthropicConfig
from .atlascloud_config import ATLASCLOUD_API_PARAMS, AtlasCloudConfig
+from .avian_config import AVIAN_API_PARAMS, AvianConfig
from .base_config import BaseConfig
from .bedrock_config import BEDROCK_API_PARAMS, BedrockConfig
from .cerebras_config import CEREBRAS_API_PARAMS, CerebrasConfig
@@ -148,4 +149,6 @@ __all__ = [
'FUNCTION_GEMMA_API_PARAMS',
'VolcanoConfig',
'VOLCANO_API_PARAMS',
+ 'AvianConfig',
+ 'AVIAN_API_PARAMS',
]
diff --git a/camel/configs/avian_config.py b/camel/configs/avian_config.py
new file mode 100644
index 000000000..49d6b2cef
--- /dev/null
+++ b/camel/configs/avian_config.py
@@ -0,0 +1,73 @@
+# ========= Copyright 2023-2026 @ 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-2026 @ CAMEL-AI.org. All Rights Reserved. =========
+from __future__ import annotations
+
+from typing import Dict, Optional, Sequence, Union
+
+from camel.configs.base_config import BaseConfig
+
+
+class AvianConfig(BaseConfig):
+ r"""Defines the parameters for generating chat completions using the
+ Avian API.
+
+ Reference: https://avian.io/docs
+
+ Args:
+ temperature (float, optional): Sampling temperature to use, between
+ :obj:`0` and :obj:`2`. Higher values make the output more random,
+ while lower values make it more focused and deterministic.
+ (default: :obj:`None`)
+ top_p (float, optional): An alternative to sampling with temperature,
+ called nucleus sampling, where the model considers the results of
+ the tokens with top_p probability mass. So :obj:`0.1` means only
+ the tokens comprising the top 10% probability mass are considered.
+ (default: :obj:`None`)
+ response_format (object, optional): An object specifying the format
+ that the model must output. Setting to {"type": "json_object"}
+ enables JSON mode, which guarantees the message the model
+ generates is valid JSON. (default: :obj:`None`)
+ stream (bool, optional): If True, partial message deltas will be sent
+ as data-only server-sent events as they become available.
+ (default: :obj:`None`)
+ stop (str or list, optional): Up to :obj:`4` sequences where the API
+ will stop generating further tokens. (default: :obj:`None`)
+ max_tokens (int, optional): The maximum number of tokens to generate
+ in the chat completion. The total length of input tokens and
+ generated tokens is limited by the model's context length.
+ (default: :obj:`None`)
+ tool_choice (Union[dict[str, str], str], optional): Controls which (if
+ any) tool is called by the model. :obj:`"none"` means the model
+ will not call any tool and instead generates a message.
+ :obj:`"auto"` means the model can pick between generating a
+ message or calling one or more tools. :obj:`"required"` means the
+ model must call one or more tools. Specifying a particular tool
+ via {"type": "function", "function": {"name": "my_function"}}
+ forces the model to call that tool. :obj:`"none"` is the default
+ when no tools are present. :obj:`"auto"` is the default if tools
+ are present.
+ """
+
+ temperature: Optional[float] = None
+ top_p: Optional[float] = None
+ stream: Optional[bool] = None
+ stop: Optional[Union[str, Sequence[str]]] = None
+ max_tokens: Optional[int] = None
+ response_format: Optional[Dict] = None
+ tool_choice: Optional[
+ Union[Dict[str, Union[str, Dict[str, str]]], str]
+ ] = None
+
+
+AVIAN_API_PARAMS = {param for param in AvianConfig.model_fields.keys()}
diff --git a/camel/models/__init__.py b/camel/models/__init__.py
index a26b7f2ca..85190a2e6 100644
--- a/camel/models/__init__.py
+++ b/camel/models/__init__.py
@@ -16,6 +16,7 @@ from .aiml_model import AIMLModel
from .amd_model import AMDModel
from .anthropic_model import AnthropicModel
from .atlascloud_model import AtlasCloudModel
+from .avian_model import AvianModel
from .aws_bedrock_model import AWSBedrockModel
from .azure_openai_model import AzureOpenAIModel
from .base_audio_model import BaseAudioModel
@@ -116,4 +117,5 @@ __all__ = [
'CrynuxModel',
'AihubMixModel',
'FunctionGemmaModel',
+ 'AvianModel',
]
diff --git a/camel/models/avian_model.py b/camel/models/avian_model.py
new file mode 100644
index 000000000..36d8ebb61
--- /dev/null
+++ b/camel/models/avian_model.py
@@ -0,0 +1,86 @@
+# ========= Copyright 2023-2026 @ 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-2026 @ CAMEL-AI.org. All Rights Reserved. =========
+import os
+from typing import Any, Dict, Optional, Union
+
+from camel.configs import AvianConfig
+from camel.models.openai_compatible_model import OpenAICompatibleModel
+from camel.types import ModelType
+from camel.utils import (
+ BaseTokenCounter,
+ api_keys_required,
+)
+
+
+class AvianModel(OpenAICompatibleModel):
+ r"""LLM API served by Avian in a unified OpenAICompatibleModel interface.
+
+ Args:
+ model_type (Union[ModelType, str]): Model for which a backend is
+ created, such as :obj:`ModelType.AVIAN_DEEPSEEK_V3_2` or a string
+ like :obj:`"deepseek/deepseek-v3.2"`.
+ model_config_dict (Optional[Dict[str, Any]], optional): A dictionary
+ that will be fed into:obj:`openai.ChatCompletion.create()`.
+ If:obj:`None`, :obj:`AvianConfig().as_dict()` will be used.
+ (default: :obj:`None`)
+ api_key (Optional[str], optional): The API key for authenticating
+ with the Avian service. (default: :obj:`None`).
+ url (Optional[str], optional): The url to the Avian service.
+ (default: :obj:`None`)
+ token_counter (Optional[BaseTokenCounter], optional): Token counter to
+ use for the model. If not provided, :obj:`OpenAITokenCounter(
+ ModelType.GPT_4O_MINI)` will be used.
+ (default: :obj:`None`)
+ timeout (Optional[float], optional): The timeout value in seconds for
+ API calls. If not provided, will fall back to the MODEL_TIMEOUT
+ environment variable or default to 180 seconds.
+ (default: :obj:`None`)
+ max_retries (int, optional): Maximum number of retries for API calls.
+ (default: :obj:`3`)
+ **kwargs (Any): Additional arguments to pass to the client
+ initialization.
+
+ References:
+ https://avian.io/docs
+ """
+
+ @api_keys_required([("api_key", "AVIAN_API_KEY")])
+ def __init__(
+ self,
+ model_type: Union[ModelType, str],
+ model_config_dict: Optional[Dict[str, Any]] = None,
+ api_key: Optional[str] = None,
+ url: Optional[str] = None,
+ token_counter: Optional[BaseTokenCounter] = None,
+ timeout: Optional[float] = None,
+ max_retries: int = 3,
+ **kwargs: Any,
+ ) -> None:
+ if model_config_dict is None:
+ model_config_dict = AvianConfig().as_dict()
+ api_key = api_key or os.environ.get("AVIAN_API_KEY")
+ url = url or os.environ.get(
+ "AVIAN_API_BASE_URL", "https://api.avian.io/v1"
+ )
+ timeout = timeout or float(os.environ.get("MODEL_TIMEOUT", 180))
+ super().__init__(
+ model_type=model_type,
+ model_config_dict=model_config_dict,
+ api_key=api_key,
+ url=url,
+ token_counter=token_counter,
+ timeout=timeout,
+ max_retries=max_retries,
+ **kwargs,
+ )
diff --git a/camel/models/model_factory.py b/camel/models/model_factory.py
index dd08254ed..481e40e34 100644
--- a/camel/models/model_factory.py
+++ b/camel/models/model_factory.py
@@ -20,6 +20,7 @@ from camel.models.aiml_model import AIMLModel
from camel.models.amd_model import AMDModel
from camel.models.anthropic_model import AnthropicModel
from camel.models.atlascloud_model import AtlasCloudModel
+from camel.models.avian_model import AvianModel
from camel.models.aws_bedrock_model import AWSBedrockModel
from camel.models.azure_openai_model import AzureOpenAIModel
from camel.models.base_model import BaseModelBackend
@@ -116,6 +117,7 @@ class ModelFactory:
ModelPlatformType.QIANFAN: QianfanModel,
ModelPlatformType.CRYNUX: CrynuxModel,
ModelPlatformType.AIHUBMIX: AihubMixModel,
+ ModelPlatformType.AVIAN: AvianModel,
ModelPlatformType.FUNCTION_GEMMA: FunctionGemmaModel,
}
diff --git a/camel/types/enums.py b/camel/types/enums.py
index 70a7f19f2..6aebe0637 100644
--- a/camel/types/enums.py
+++ b/camel/types/enums.py
@@ -532,6 +532,12 @@ class ModelType(UnifiedModelType, Enum):
MINIMAX_M2 = "MiniMax-M2"
MINIMAX_M2_STABLE = "MiniMax-M2-Stable"
+ # Avian models
+ AVIAN_DEEPSEEK_V3_2 = "deepseek/deepseek-v3.2"
+ AVIAN_KIMI_K2_5 = "moonshotai/kimi-k2.5"
+ AVIAN_GLM_5 = "z-ai/glm-5"
+ AVIAN_MINIMAX_M2_5 = "minimax/minimax-m2.5"
+
# AtlasCloud models
ATLASCLOUD_GPT_OSS_120B = "openai/gpt-oss-120b"
ATLASCLOUD_GLM_4_7 = "zai-org/glm-4.7"
@@ -593,6 +599,7 @@ class ModelType(UnifiedModelType, Enum):
self.is_aiml,
self.is_azure_openai,
self.is_novita,
+ self.is_avian,
]
)
@@ -1192,6 +1199,16 @@ class ModelType(UnifiedModelType, Enum):
ModelType.AIML_MISTRAL_7B_INSTRUCT,
}
+ @property
+ def is_avian(self) -> bool:
+ r"""Returns whether this type of models is served by Avian."""
+ return self in {
+ ModelType.AVIAN_DEEPSEEK_V3_2,
+ ModelType.AVIAN_KIMI_K2_5,
+ ModelType.AVIAN_GLM_5,
+ ModelType.AVIAN_MINIMAX_M2_5,
+ }
+
@property
def is_atlascloud(self) -> bool:
r"""Returns whether this type of models is served by AtlasCloud."""
@@ -1552,8 +1569,14 @@ class ModelType(UnifiedModelType, Enum):
ModelType.NOVITA_LLAMA_3_3_70B,
ModelType.NOVITA_MISTRAL_NEMO,
ModelType.NEBIUS_LLAMA_3_1_70B,
+ ModelType.AVIAN_KIMI_K2_5,
+ ModelType.AVIAN_GLM_5,
}:
return 131_072
+ elif self in {
+ ModelType.AVIAN_DEEPSEEK_V3_2,
+ }:
+ return 164_000
elif self in {
ModelType.O1,
ModelType.O3_MINI,
@@ -1633,6 +1656,7 @@ class ModelType(UnifiedModelType, Enum):
ModelType.GPT_4_1_MINI,
ModelType.GPT_4_1_NANO,
ModelType.NOVITA_LLAMA_4_MAVERICK_17B,
+ ModelType.AVIAN_MINIMAX_M2_5,
}:
return 1_048_576
elif self in {
@@ -1888,6 +1912,7 @@ class ModelPlatformType(Enum):
MINIMAX = "minimax"
CEREBRAS = "cerebras"
FUNCTION_GEMMA = "function-gemma"
+ AVIAN = "avian"
ATLASCLOUD = "atlascloud"
@classmethod
@@ -2084,6 +2109,11 @@ class ModelPlatformType(Enum):
r"""Returns whether this platform is Cerebras."""
return self is ModelPlatformType.CEREBRAS
+ @property
+ def is_avian(self) -> bool:
+ r"""Returns whether this platform is Avian."""
+ return self is ModelPlatformType.AVIAN
+
@property
def is_atlascloud(self) -> bool:
r"""Returns whether this platform is AtlasCloud."""
diff --git a/camel/types/unified_model_type.py b/camel/types/unified_model_type.py
index ca34fb679..db2d7fc9d 100644
--- a/camel/types/unified_model_type.py
+++ b/camel/types/unified_model_type.py
@@ -109,6 +109,11 @@ class UnifiedModelType(str):
r"""Returns whether the model is a OpenRouter served model."""
return True
+ @property
+ def is_avian(self) -> bool:
+ r"""Returns whether the model is an Avian served model."""
+ return True
+
@property
def is_atlascloud(self) -> bool:
r"""Returns whether the model is a AtlasCloud served model."""
diff --git a/camel/utils/commons.py b/camel/utils/commons.py
index 5b8e9ee48..604036a26 100644
--- a/camel/utils/commons.py
+++ b/camel/utils/commons.py
@@ -361,6 +361,8 @@ def api_keys_required(
key_way = "https://www.klavis.ai/docs"
elif env_var_name == 'XAI_API_KEY':
key_way = "https://docs.x.ai/docs/overview"
+ elif env_var_name == 'AVIAN_API_KEY':
+ key_way = "https://avian.io"
if missing_keys:
raise ValueError(
diff --git a/test/models/test_avian_model.py b/test/models/test_avian_model.py
new file mode 100644
index 000000000..833153b20
--- /dev/null
+++ b/test/models/test_avian_model.py
@@ -0,0 +1,41 @@
+# ========= Copyright 2023-2026 @ 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-2026 @ CAMEL-AI.org. All Rights Reserved. =========
+
+import pytest
+
+from camel.configs import AvianConfig
+from camel.models import AvianModel
+from camel.types import ModelType
+from camel.utils import OpenAITokenCounter
+
+
+ "model_type",
+ [
+ ModelType.AVIAN_DEEPSEEK_V3_2,
+ ModelType.AVIAN_KIMI_K2_5,
+ ModelType.AVIAN_GLM_5,
+ ModelType.AVIAN_MINIMAX_M2_5,
+ ],
+)
+def test_avian_model(model_type: ModelType, monkeypatch):
+ monkeypatch.setenv("AVIAN_API_KEY", "test_key")
+ model_config_dict = AvianConfig().as_dict()
+ model = AvianModel(model_type, model_config_dict)
+ assert model.model_type == model_type
+ assert model.model_config_dict == model_config_dict
+ assert isinstance(model.token_counter, OpenAITokenCounter)
+ assert isinstance(model.model_type.value_for_tiktoken, str)
+ assert isinstance(model.model_type.token_limit, int)