Watsonx.ai AI Models

IBM Watsonx.ai models provide a comprehensive suite of AI capabilities including chat models, embedding models, and moderation. This documentation covers the integration of Watsonx.ai services with Spring AI applications.

Overview

Watsonx.ai offers several powerful AI models:

  • Chat Models: Conversational AI models for building intelligent chatbots and assistants

  • Embedding Models: Text embedding models for semantic search and similarity analysis

  • Moderation Models: Content moderation capabilities for safe and responsible AI

Documentation Navigation

Explore the complete documentation:

Prerequisites

To use the Watsonx.ai models, you need to:

  1. Create an account at IBM Cloud

  2. Set up a Watsonx.ai service instance

  3. Generate API keys from the IBM Cloud console

Quick Start

To get started with Watsonx.ai models in your application, add the following dependency:

Maven
<dependency>
    <groupId>org.springaicommunity</groupId>
    <artifactId>spring-ai-starter-model-watsonx-ai</artifactId>
    <version>1.0.0</version>
</dependency>
Gradle
implementation 'org.springaicommunity:spring-ai-starter-model-watsonx-ai:1.0.0'

Configure your Watsonx.ai credentials in application.yml:

spring:
  ai:
    watsonx:
      ai:
        api-key: ${WATSONX_AI_API_KEY}
        url: ${WATSONX_AI_URL}
        project-id: ${WATSONX_AI_PROJECT_ID}

Or in application.properties:

spring.ai.watsonx.ai.api-key=${WATSONX_AI_API_KEY}
spring.ai.watsonx.ai.url=${WATSONX_AI_URL}
spring.ai.watsonx.ai.project-id=${WATSONX_AI_PROJECT_ID}

Set your credentials as environment variables:

export WATSONX_AI_API_KEY=<INSERT API KEY HERE>
export WATSONX_AI_URL=<INSERT WATSONX AI URL HERE>
export WATSONX_AI_PROJECT_ID=<INSERT PROJECT ID HERE>
For more configuration options, see the Configuration Guide.

Source Code

The source code for this project is available on GitHub at spring-ai-community/spring-ai-watsonx-ai.

Available Services

Service Description

Chat Models

Build conversational AI applications with Watsonx.ai’s various chat models

Embedding Models

Generate text embeddings for semantic search and text similarity analysis

Moderation Models

Content moderation capabilities for safe and responsible AI applications

Architecture

The Spring AI Watsonx.ai integration consists of three main modules:

  • watsonx-ai-core: Core implementation with API clients and model classes

  • spring-ai-autoconfigure-model-watsonx-ai: Spring Boot auto-configuration

  • spring-ai-starter-model-watsonx-ai: Spring Boot starter for easy integration

Supported Models

Chat Models

  • IBM Granite models

  • Meta Llama models

  • Mistral AI models

  • And other foundation models available in Watsonx.ai

Embedding Models

  • IBM’s embedding models

  • Sentence transformers

  • Custom embedding models deployed in Watsonx.ai

Moderation Models

  • IBM’s content moderation models

  • Toxicity detection

  • Hate speech detection

  • PII (Personally Identifiable Information) detection

  • Custom moderation models

Getting Help

If you encounter issues or have questions: