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

# autogen.oai.ollama.OllamaClient

<h2 id="autogen.oai.ollama.OllamaClient" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">OllamaClient</span>
</h2>

```python theme={null}
OllamaClient(response_format: Optional[Union[BaseModel, dict[str, Any]]] = None, **kwargs)
```

Client for Ollama's API.<br />Note that no api\_key or environment variable is required for Ollama.

<b>Parameters:</b>

| Name              | Description                                                                          |
| ----------------- | ------------------------------------------------------------------------------------ |
| `response_format` | **Type:** Optional\[Union\[BaseModel, dict\[str, Any]]]<br /><br />**Default:** None |
| `**kwargs`        |                                                                                      |

### Class Attributes

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### TOOL\_CALL\_MANUAL\_INSTRUCTION

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### TOOL\_CALL\_MANUAL\_STEP1

<br />

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-attribute" />

#### TOOL\_CALL\_MANUAL\_STEP2

<br />

<br />

### Static Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### get\_usage

```python theme={null}
get_usage(response) -> dict
```

Return usage summary of the response using RESPONSE\_USAGE\_KEYS.

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `response` |             |

<br />

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### cost

```python theme={null}
cost(self, response) -> float
```

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `response` |             |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### create

```python theme={null}
create(self, params: dict) -> ChatCompletionExtended
```

<b>Parameters:</b>

| Name     | Description    |
| -------- | -------------- |
| `params` | **Type:** dict |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### message\_retrieval

```python theme={null}
message_retrieval(self, response) -> list
```

Retrieve and return a list of strings or a list of Choice.Message from the response.<br />NOTE: if a list of Choice.Message is returned, it currently needs to contain the fields of OpenAI's ChatCompletion Message object,
since that is expected for function or tool calling in the rest of the codebase at the moment, unless a custom agent is being used.

<b>Parameters:</b>

| Name       | Description |
| ---------- | ----------- |
| `response` |             |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### oai\_messages\_to\_ollama\_messages

```python theme={null}
oai_messages_to_ollama_messages(
    self,
    messages: list[dict[str, Any]],
    tools: list
) -> list[dict[str, Any]]
```

Convert messages from OAI format to Ollama's format.<br />We correct for any specific role orders and types, and convert tools to messages (as Ollama can't use tool messages)

<b>Parameters:</b>

| Name       | Description                      |
| ---------- | -------------------------------- |
| `messages` | **Type:** list\[dict\[str, Any]] |
| `tools`    | **Type:** list                   |

<br />

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### parse\_params

```python theme={null}
parse_params(self, params: dict[str, Any]) -> dict[str, Any]
```

Loads the parameters for Ollama API from the passed in parameters and returns a validated set. Checks types, ranges, and sets defaults

<b>Parameters:</b>

| Name     | Description               |
| -------- | ------------------------- |
| `params` | **Type:** dict\[str, Any] |

<br />
