Oven logo

Oven

Published

IBM watsonx.ai API Client

pip install ibm-watsonx-ai

Package Downloads

Weekly DownloadsMonthly Downloads

Authors

Requires Python

<3.14,>=3.11

πŸ“¦ ibm-watsonx-ai

Official IBM watsonx.ai Python SDK


IBM Python License

PyPI Downloads Docs Examples


Enterprise-grade Python client for building, tuning and deploying AI models with IBM watsonx.ai

πŸš€ Quick Start β€’ πŸ“˜ Documentation β€’ πŸ““ Examples

πŸ“Œ Overview

ibm-watsonx-ai is the official Python SDK for IBM watsonx.ai, an enterprise-grade AI platform for building, training, tuning, deploying, and operating AI models at scale.

The SDK provides a unified and production-ready Python interface to the full watsonx.ai ecosystem, including Foundation Models (within LLMs), AutoAI experiments, Retrieval-Augmented Generation (RAG), model tuning, deployment, and data integration.

With ibm-watsonx-ai, developers and data scientists can seamlessly integrate advanced AI capabilities into Python applications running on IBM watsonx.ai for IBM Cloud or IBM watsonx.ai software, while meeting enterprise requirements such as security, governance, and scalability.


🎯 What This SDK Is Used For

The ibm-watsonx-ai SDK is designed to support the entire AI lifecycle:

  • πŸ” Secure authentication and environment configuration
  • πŸ€– Inference with Foundation Models (LLMs, embeddings, time-series, audio)
  • πŸ“š Building Retrieval-Augmented Generation (RAG) systems
  • πŸ§ͺ Running and optimizing AutoAI experiments
  • βš™οΈ Fine-tuning and prompt tuning of models
  • πŸš€ Deploying models to scalable inference endpoints
  • πŸ”— Integrating enterprise data sources into AI workflows

It is suitable for research, prototyping, and production deployments.


πŸ“¦ Installation

Install from PyPI:

pip install ibm-watsonx-ai

Install with optional extras:

pip install "ibm-watsonx-ai[rag]"
ExtraDescription
ragRetrieval‑Augmented Generation utilities
mcpModel Context Protocol

πŸš€ Quick Start

Authentication

from ibm_watsonx_ai import Credentials, APIClient

credentials = Credentials(
    url="https://us-south.ml.cloud.ibm.com",
    api_key="<your-ibm-api-key>"
)

api_client = APIClient(credentials, space_id="<your-space-id>")

Working with ModelInference

Get available models

list(api_client.foundation_models.ChatModels)

# [<ChatModels.GRANITE_3_3_8B_INSTRUCT: 'ibm/granite-3-3-8b-instruct'>,
#  <ChatModels.GRANITE_4_H_SMALL: 'ibm/granite-4-h-small'>,
#  <ChatModels.LLAMA_3_3_70B_INSTRUCT: 'meta-llama/llama-3-3-70b-instruct'>,
#  <ChatModels.GPT_OSS_120B: 'openai/gpt-oss-120b'>]

Initialisation

from ibm_watsonx_ai.foundation_models import ModelInference

model = ModelInference(
    api_client=api_client,
    model_id="ibm/granite-4-h-small"
)

Chat with model

messages = [
    {"role": "system", "content": "You are a helpful assistant that translates English to French."},
    {"role": "user", "content": "I love you for listening to Rock."}
]

model.chat(messages=messages)