# WatsonxToolkit

> **Class** in `langchain_ibm`

📖 [View in docs](https://reference.langchain.com/python/langchain-ibm/agent_toolkits/utility/toolkit/WatsonxToolkit)

IBM watsonx.ai Toolkit.

???+ info "Setup"

    To use, you should have `langchain_ibm` python package installed,
    and the environment variable `WATSONX_API_KEY` set with your API key, or pass
    it as a named parameter `api_key` to the constructor.

    ```bash
    pip install -U langchain-ibm

    # or using uv
    uv add langchain-ibm
    ```

    ```bash
    export WATSONX_API_KEY="your-api-key"
    ```

    !!! deprecated
        `apikey` and `WATSONX_APIKEY` are deprecated and will be removed in
        version `2.0.0`. Use `api_key` and `WATSONX_API_KEY` instead.

??? info "Instantiate"

    IBM watsonx.ai for IBM Cloud:

    ```python
    from langchain_ibm.agent_toolkits.utility import WatsonxToolkit

    watsonx_toolkit = WatsonxToolkit(
        url="https://us-south.ml.cloud.ibm.com",
        project_id="*****",  # or `space_id`
        api_key="*****",  # not needed if `WATSONX_API_KEY` is set
    )
    ```

    IBM watsonx.ai software:
    ```python
    from langchain_ibm.agent_toolkits.utility import WatsonxToolkit

    watsonx_toolkit = WatsonxToolkit(
        url="<CPD_URL>",
        project_id="*****",  # or `space_id`
        username="*****",
        password="*****",
        instance_id="*****",
        version="*****",  # optional
    )
    ```

??? info "Invoke"

    ```python
    tools = watsonx_toolkit.get_tools()

    google_search = watsonx_toolkit.get_tool(tool_name="GoogleSearch")

    tool_config = {
        "maxResults": 3,
    }
    google_search.set_tool_config(tool_config)
    input = {
        "input": "Search IBM",
    }
    search_result = google_search.invoke(input)
    ```

??? info "Run"

    ```python
    rag_query = watsonx_toolkit.get_tool(tool_name="RAGQuery")

    rag_query.set_tool_config(
        {
            "vectorIndexId": "<vector-index-id>",
            "projectId": "<project-id>",
        }
    )

    res = rag_query.run("How to initialize APIClient?")
    ```

## Signature

```python
WatsonxToolkit()
```

## Extends

- `BaseToolkit`

## Properties

- `project_id`
- `space_id`
- `url`
- `apikey`
- `api_key`
- `token`
- `password`
- `username`
- `instance_id`
- `version`
- `verify`
- `watsonx_client`
- `model_config`

## Methods

- [`validate_environment()`](https://reference.langchain.com/python/langchain-ibm/agent_toolkits/utility/toolkit/WatsonxToolkit/validate_environment)
- [`get_tools()`](https://reference.langchain.com/python/langchain-ibm/agent_toolkits/utility/toolkit/WatsonxToolkit/get_tools)
- [`get_tool()`](https://reference.langchain.com/python/langchain-ibm/agent_toolkits/utility/toolkit/WatsonxToolkit/get_tool)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-ibm/blob/68e9b09f8cbc8d2310e57a6a7eb51cde0956a3b0/libs/ibm/langchain_ibm/agent_toolkits/utility/toolkit.py#L116)