> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# IBM WatsonX

> Use IBM WatsonX foundation models with Agno agents.

IBM WatsonX provides access to foundation models through IBM's cloud platform.

See all the IBM WatsonX supported models [here](https://www.ibm.com/products/watsonx-ai/foundation-models).

* We recommend using `meta-llama/llama-3-3-70b-instruct` for general use
* We recommend `ibm/granite-20b-code-instruct` for code-related tasks
* We recommend using `meta-llama/llama-3-2-11b-vision-instruct` for image understanding

## Multimodal Support

With WatsonX we support `Image` as input.

## Installation

```bash theme={null}
uv pip install -U ibm-watsonx-ai agno
```

## Authentication

Set your `IBM_WATSONX_API_KEY` and `IBM_WATSONX_PROJECT_ID` environment variables. Get your credentials from [IBM Cloud](https://cloud.ibm.com/).
You can also set the `IBM_WATSONX_URL` environment variable to the URL of the WatsonX API you want to use. It defaults to `https://eu-de.ml.cloud.ibm.com`.

```bash Mac theme={null}
export IBM_WATSONX_API_KEY=***
export IBM_WATSONX_PROJECT_ID=***
```

```bash Windows theme={null}
setx IBM_WATSONX_API_KEY ***
setx IBM_WATSONX_PROJECT_ID ***
```

## Example

Use `WatsonX` with your `Agent`:

```python agent.py theme={null}
from agno.agent import Agent
from agno.models.ibm import WatsonX

agent = Agent(
    model=WatsonX(id="meta-llama/llama-3-3-70b-instruct"),
    markdown=True
)

# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story.")

```

> [!NOTE]
>
> View more examples [here](https://agno-v2.mintlify.site/models/providers/cloud/ibm-watsonx/usage/basic-stream.md).

## Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `id` | `str` | `"ibm/granite-20b-code-instruct"` | The id of the IBM watsonx model to use |
| `name` | `str` | `"WatsonX"` | The name of the model |
| `provider` | `str` | `"IBM"` | The provider of the model |
| `frequency_penalty` | `Optional[float]` | `None` | Penalizes new tokens based on their frequency in the text so far |
| `presence_penalty` | `Optional[float]` | `None` | Penalizes new tokens based on whether they appear in the text so far |
| `max_tokens` | `Optional[int]` | `None` | Maximum number of tokens to generate |
| `temperature` | `Optional[float]` | `None` | Controls randomness in the model's output |
| `top_p` | `Optional[float]` | `None` | Controls diversity via nucleus sampling |
| `logprobs` | `Optional[int]` | `None` | Return log probabilities of the output tokens |
| `top_logprobs` | `Optional[int]` | `None` | Number of most likely tokens to return log probabilities for |
| `request_params` | `Optional[Dict[str, Any]]` | `None` | Additional parameters to include in the request |
| `api_key` | `Optional[str]` | `None` | The API key for IBM watsonx (defaults to IBM\_WATSONX\_API\_KEY env var) |
| `project_id` | `Optional[str]` | `None` | The project ID for IBM watsonx (defaults to IBM\_WATSONX\_PROJECT\_ID env var) |
| `url` | `Optional[str]` | `"https://eu-de.ml.cloud.ibm.com"` | The watsonx endpoint URL (IBM\_WATSONX\_URL env var takes precedence) |
| `verify` | `bool` | `True` | Verify TLS certificates when connecting |
| `client_params` | `Optional[Dict[str, Any]]` | `None` | Additional parameters for client configuration |

`WatsonX` is a subclass of the [Model](https://agno-v2.mintlify.site/reference/models/model.md) class and has access to the same params.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.