> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.models.model manager

<a id="camel.models.model_manager" />

<a id="camel.models.model_manager.ModelProcessingError" />

## ModelProcessingError

```python theme={"system"}
class ModelProcessingError(Exception):
```

Raised when an error occurs during model processing.

<a id="camel.models.model_manager.ModelManager" />

## ModelManager

```python theme={"system"}
class ModelManager:
```

ModelManager choosing a model from provided list.
Models are picked according to defined strategy.

**Parameters:**

* **models** (Union\[BaseModelBackend, List\[BaseModelBackend]]): model backend or list of model backends (e.g., model instances, APIs)
* **scheduling\_strategy** (str): name of function that defines how to select the next model. (default: :str:`round_robin`)

<a id="camel.models.model_manager.ModelManager.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    models: Union[BaseModelBackend, List[BaseModelBackend]],
    scheduling_strategy: str = 'round_robin'
):
```

<a id="camel.models.model_manager.ModelManager.model_type" />

### model\_type

```python theme={"system"}
def model_type(self):
```

**Returns:**

Union\[ModelType, str]: Current model type.

<a id="camel.models.model_manager.ModelManager.model_config_dict" />

### model\_config\_dict

```python theme={"system"}
def model_config_dict(self):
```

**Returns:**

Dict\[str, Any]: Config dictionary of the current model.

<a id="camel.models.model_manager.ModelManager.model_config_dict" />

### model\_config\_dict

```python theme={"system"}
def model_config_dict(self, model_config_dict: Dict[str, Any]):
```

Set model\_config\_dict to the current model.

**Parameters:**

* **model\_config\_dict** (Dict\[str, Any]): Config dictionary to be set at current model.

<a id="camel.models.model_manager.ModelManager.current_model_index" />

### current\_model\_index

```python theme={"system"}
def current_model_index(self):
```

**Returns:**

int: index of current model in given list of models.

<a id="camel.models.model_manager.ModelManager.num_models" />

### num\_models

```python theme={"system"}
def num_models(self):
```

**Returns:**

int: The number of models available in the model manager.

<a id="camel.models.model_manager.ModelManager.token_limit" />

### token\_limit

```python theme={"system"}
def token_limit(self):
```

**Returns:**

int: The maximum token limit for the given model.

<a id="camel.models.model_manager.ModelManager.token_counter" />

### token\_counter

```python theme={"system"}
def token_counter(self):
```

**Returns:**

BaseTokenCounter: The token counter following the model's
tokenization style.

<a id="camel.models.model_manager.ModelManager.add_strategy" />

### add\_strategy

```python theme={"system"}
def add_strategy(self, name: str, strategy_fn: Callable):
```

Add a scheduling strategy method provided by user in case when none
of existent strategies fits.
When custom strategy is provided, it will be set as
"self.scheduling\_strategy" attribute.

**Parameters:**

* **name** (str): The name of the strategy.
* **strategy\_fn** (Callable): The scheduling strategy function.

<a id="camel.models.model_manager.ModelManager.round_robin" />

### round\_robin

```python theme={"system"}
def round_robin(self):
```

**Returns:**

BaseModelBackend for processing incoming messages.

<a id="camel.models.model_manager.ModelManager.always_first" />

### always\_first

```python theme={"system"}
def always_first(self):
```

**Returns:**

BaseModelBackend for processing incoming messages.

<a id="camel.models.model_manager.ModelManager.random_model" />

### random\_model

```python theme={"system"}
def random_model(self):
```

**Returns:**

BaseModelBackend for processing incoming messages.

<a id="camel.models.model_manager.ModelManager.run" />

### run

```python theme={"system"}
def run(
    self,
    messages: List[OpenAIMessage],
    response_format: Optional[Type[BaseModel]] = None,
    tools: Optional[List[Dict[str, Any]]] = None
):
```

Process a list of messages by selecting a model based on
the scheduling strategy.
Sends the entire list of messages to the selected model,
and returns a single response.

**Parameters:**

* **messages** (List\[OpenAIMessage]): Message list with the chat history in OpenAI API format.

**Returns:**

Union\[ChatCompletion, Stream\[ChatCompletionChunk],
ChatCompletionStreamManager\[BaseModel]]:
`ChatCompletion` in the non-stream mode, or
`Stream[ChatCompletionChunk]` in the stream mode, or
`ChatCompletionStreamManager[BaseModel]` for
structured-output stream.
