ibm-watsonx-ai

IBM watsonx.ai API Client

BSD-3-Clause 108 个版本 Python <3.15,>=3.11
安装
pip install ibm-watsonx-ai
poetry add ibm-watsonx-ai
pipenv install ibm-watsonx-ai
conda install ibm-watsonx-ai
描述

📦 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]"
Extra Description
rag Retrieval‑Augmented Generation utilities
mcp Model Context Protocol

🚀 Quick Start

Authentication

Set up your Credentials and create an APIClient instance:

from ibm_watsonx_ai import Credentials, APIClient

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

# Initialize APIClient using a space ID (you can also use a project ID)
api_client = APIClient(credentials, space_id="<your-space-id>")

Working with ModelInference

List available chat models

list(api_client.foundation_models.ChatModels)

# Output example:
# [<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'>]

Initialize ModelInference

from ibm_watsonx_ai.foundation_models import ModelInference

# Create a `ModelInference` instance for the selected model
model = ModelInference(
    api_client=api_client,
    model_id="ibm/granite-4-h-small"
)

Chat with the model

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

# Get model response
response = model.chat(messages=messages)
print(response)
版本列表
1.5.14 2026-06-22
1.5.13 2026-06-03
1.5.12 2026-05-20
1.5.11 2026-04-30
1.5.10 2026-04-21
1.5.9 2026-04-17
1.5.8 2026-04-10
1.5.7 2026-04-01
1.5.6 2026-04-10
1.5.5 2026-03-25
1.5.4 2026-03-17
1.5.3 2026-02-26
1.5.2 2026-02-12
1.5.1 2026-01-29
1.5.0 2026-01-14
1.4.11 2025-12-08
1.4.9 2025-12-05
1.4.8 2025-11-18
1.4.7 2025-11-18
1.4.6 2025-11-13
1.4.5 2025-11-05
1.4.4 2025-10-29
1.4.3 2025-10-29
1.4.2 2025-10-22
1.4.1 2025-10-15
1.4.0 2025-10-08
1.3.42 2025-10-01
1.3.40 2025-09-24
1.3.39 2025-09-24
1.3.38 2025-09-11
1.3.37 2025-09-04
1.3.36 2025-08-28
1.3.34 2025-08-13
1.3.33 2025-07-23
1.3.32 2025-07-23
1.3.31 2025-07-16
1.3.30 2025-07-07
1.3.28 2025-07-02
1.3.26 2025-06-12
1.3.25 2025-06-12
1.3.24 2025-06-06
1.3.23 2025-05-28
1.3.20 2025-05-16
1.3.19 2025-05-22
1.3.18 2025-05-15
1.3.17 2025-05-07
1.3.16 2025-05-06
1.3.13 2025-04-24
1.3.12 2025-04-23
1.3.11 2025-04-23
1.3.8 2025-04-16
1.3.6 2025-04-09
1.3.5 2025-04-02
1.3.3 2025-03-26
1.3.1 2025-03-19
1.3.0 2025-03-12
1.2.10 2025-03-04
1.2.9 2025-02-26
1.2.8 2025-02-19
1.2.7 2025-02-12
1.2.6 2025-01-31
1.2.5 2025-01-29
1.2.4 2025-01-29
1.2.2 2025-01-22
1.2.1 2025-01-13
1.1.26 2024-12-12
1.1.26.post1 2025-05-12
1.1.25 2024-12-05
1.1.24 2024-11-18
1.1.23 2024-11-05
1.1.22 2024-10-31
1.1.21 2024-10-29
1.1.20 2024-10-25
1.1.17 2024-10-28
1.1.16 2024-10-21
1.1.15 2024-10-16
1.1.14 2024-10-08
1.1.11 2024-09-23
1.1.9 2024-09-16
1.1.8 2024-09-02
1.1.7 2024-08-27
1.1.6 2024-08-14
1.1.6.post1 2025-04-14
1.1.5 2024-08-06
1.1.2 2024-07-24
1.0.12 2024-07-31
1.0.11 2024-07-08
1.0.10 2024-07-01
1.0.9 2024-06-21
1.0.8 2024-06-13
1.0.6 2024-06-06
1.0.5 2024-05-31
1.0.4 2024-05-17
1.0.2 2024-05-07
1.0.1 2024-04-29
0.2.6 2024-04-19
0.2.4 2024-04-05
0.2.3 2024-03-21
0.2.2 2024-03-06
0.2.0 2024-02-28
0.1.8 2024-02-15
0.1.7 2024-02-07
0.1.6 2024-02-01
0.1.5 2024-01-25
0.1.4 2024-01-18
0.1.2 2023-12-13
0.1.1 2023-12-07
0.0.5 2023-11-27