# WatsonxLLM

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/llms/watsonxllm/WatsonxLLM)

IBM watsonx.ai large language models.

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

## Signature

```python
WatsonxLLM()
```

## Description

**Example:**

.. code-block:: python

from ibm_watsonx_ai.metanames import GenTextParamsMetaNames
parameters = {
    GenTextParamsMetaNames.DECODING_METHOD: "sample",
    GenTextParamsMetaNames.MAX_NEW_TOKENS: 100,
    GenTextParamsMetaNames.MIN_NEW_TOKENS: 1,
    GenTextParamsMetaNames.TEMPERATURE: 0.5,
    GenTextParamsMetaNames.TOP_K: 50,
    GenTextParamsMetaNames.TOP_P: 1,
}

from langchain_community.llms import WatsonxLLM
watsonx_llm = WatsonxLLM(
    model_id="google/flan-ul2",
    url="https://us-south.ml.cloud.ibm.com",
    apikey="*****",
    project_id="*****",
    params=parameters,
)

## Extends

- `BaseLLM`

## Properties

- `model_id`
- `deployment_id`
- `project_id`
- `space_id`
- `url`
- `apikey`
- `token`
- `password`
- `username`
- `instance_id`
- `version`
- `params`
- `verify`
- `streaming`
- `watsonx_model`
- `model_config`
- `lc_secrets`

## Methods

- [`is_lc_serializable()`](https://reference.langchain.com/python/langchain-community/llms/watsonxllm/WatsonxLLM/is_lc_serializable)
- [`validate_environment()`](https://reference.langchain.com/python/langchain-community/llms/watsonxllm/WatsonxLLM/validate_environment)

## ⚠️ Deprecated

Deprecated since version 0.0.18.

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/4b280287bd55b99b44db2dd849f02d66c89534d5/libs/community/langchain_community/llms/watsonxllm.py#L15)