# llm_ibm_watson

A RocketRide LLM node that connects IBM watsonx foundation models to a pipeline via the IBM Cloud API.

## What it does

Connects IBM watsonx foundation models to your pipeline via the IBM Cloud API. Used primarily as an `llm` invoke connection by agents and other nodes that need an LLM. Can also be used directly via lanes.

Uses the **ibm-watsonx-ai** SDK (`ModelInference` with `TextChatParameters`). The service URL is derived from the configured location as `https://<location>.ml.cloud.ibm.com`. The location is validated against a fixed allowlist of known IBM Cloud regions before any connection is made. Temperature is fixed at `1`.

All four configuration fields are required. The node raises a configuration error at pipeline start if the API key, location, model ID, or project ID is missing, or if the location is not a known IBM Cloud region.

Token counts are estimated with a simple word-based approximation (roughly 0.75 tokens per word) rather than the model's native tokenizer.

---

## Configuration

### Lanes

| Lane in     | Lane out  | Description                                          |
| ----------- | --------- | ---------------------------------------------------- |
| `questions` | `answers` | Send a question directly, receive a generated answer |

### Fields

| Field        | Type   | Description                                                         |
| ------------ | ------ | ------------------------------------------------------------------- |
| `apikey`     | string | IBM Cloud API key (required)                                        |
| `location`   | enum   | IBM Cloud region (required, see below)                              |
| `model`      | string | watsonx model ID, specified directly; no preset profiles (required) |
| `project_id` | string | IBM watsonx project ID (required)                                   |

### Locations

The `location` value must be one of the following known IBM Cloud regions. Any other value is rejected at startup.

| Value      | Region        |
| ---------- | ------------- |
| `us-south` | Dallas        |
| `us-east`  | Washington DC |
| `eu-gb`    | London        |
| `eu-de`    | Frankfurt     |
| `eu-es`    | Madrid        |
| `jp-tok`   | Tokyo         |
| `jp-osa`   | Osaka         |
| `au-syd`   | Sydney        |
| `ca-tor`   | Toronto       |
| `br-sao`   | Sao Paulo     |

---

## Invoke functions

When used as an `llm` invoke connection, the node exposes the following functions to connected agents and other nodes:

| Function           | Description                                        |
| ------------------ | -------------------------------------------------- |
| `ask`              | Send a question and receive the generated answer   |
| `getContextLength` | Total context window size, in tokens               |
| `getOutputLength`  | Maximum output size, in tokens                     |
| `getTokenCounter`  | Token-counting function (word-based approximation) |

---

<!-- ROCKETRIDE:GENERATED:PARAMS START -->
<!-- Generated by nodes:docs-generate. Do not edit by hand. -->

## Source

[<svg viewBox="0 0 16 16" width="15" height="15" fill="currentColor" aria-hidden="true" style="vertical-align:-0.15em;margin-right:0.35em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg> View source](https://github.com/rocketride-org/rocketride-server/tree/develop/nodes/src/nodes/llm_ibm_watson)
<!-- ROCKETRIDE:GENERATED:PARAMS END -->
