---
sidebar_label: watsonx
---

import CodeBlock from "@theme/CodeBlock";
import WatsonxExample from "@examples/watsonx-llm-example/watsonx_example.go";

# watsonx

Integration support for [IBM watsonx](https://www.ibm.com/watsonx) foundation models with [`watsonx-go`](https://github.com/IBM/watsonx-go
).

## Setup

You will need to set the following environment variables for using the WatsonX AI API.

- `WATSONX_API_KEY`: generate from your [IBM Cloud account](https://cloud.ibm.com/iam/apikeys).
- `WATSONX_PROJECT_ID`: copy from your [watsonx project settings](https://dataplatform.cloud.ibm.com/projects/?context=wx).

Alternatively, these can be passed into the model on creation:

```go
import (
	wx "github.com/IBM/watsonx-go/pkg/models"
    "github.com/tmc/langchaingo/llms/watsonx"
)
...
llm, _ := watsonx.New(
    wx.WithWatsonxAPIKey("YOUR WATSONX API KEY"),
    wx.WithWatsonxProjectID("YOUR WATSONX PROJECT ID"),
)
```

## Example

<CodeBlock language="go">{WatsonxExample}</CodeBlock>
