Skip to main content
Deprecated: The native WatsonX backend is deprecated since v0.4. Use the LiteLLM or OpenAI backend with a WatsonX-compatible endpoint instead.
The WatsonX backend connects to IBM’s managed AI platform. It requires an API key, project ID, and service URL. Prerequisites: pip install 'mellea[watsonx]' and IBM Cloud credentials.

Credentials

Obtain these from the IBM Cloud console:
  • API key: IBM Cloud IAM
  • Project ID: Your Watson Studio project settings
  • URL: Region-specific endpoint (e.g., https://us-south.ml.cloud.ibm.com)

Connecting

The quickest path is start_session() with backend_name="watsonx":
Or construct the Backend directly for full control:
Credentials are read from the environment variables by default. Pass them explicitly if needed:

Available models

Pass the WatsonX model name string directly for any model not listed in model_ids.

Troubleshooting

Missing credentials:
All three environment variables must be set. Check your IBM Cloud project settings for the correct values. pip install "mellea[watsonx]" required: The WatsonX backend requires the ibm-watson-machine-learning package, which is not installed by default:

Vision support

Note: WatsonxAIBackend does not currently support image input. Passing images=[...] to instruct() or chat() will raise an error. Use the OpenAI backend or Ollama for vision tasks.

See also: Backends and Configuration