IBM watsonx.ai Chat and Generation Models

IBM watsonx.ai enables the development of generative AI applications using foundation models from IBM and Hugging Face.

This extension supports IBM watsonx as a service on IBM Cloud only.

Prerequisites

To use watsonx.ai models, configure the following required values in your application.properties file:

Base URL

The base-url depends on the region of your service instance:

quarkus.langchain4j.watsonx.base-url=https://us-south.ml.cloud.ibm.com

Project ID

Obtain the Project Id via:

quarkus.langchain4j.watsonx.project-id=23d...
You may use the optional space-id as an alternative.

API Key

Create an API key by visiting https://cloud.ibm.com/iam/apikeys and clicking Create +.

quarkus.langchain4j.watsonx.api-key=your-api-key
You can also use the QUARKUS_LANGCHAIN4J_WATSONX_API_KEY environment variable.

Dependency

Add the following dependency to your project:

<dependency>
  <groupId>io.quarkiverse.langchain4j</groupId>
  <artifactId>quarkus-langchain4j-watsonx</artifactId>
  <version>1.13.0</version>
</dependency>

Even better, if you use the Quarkus platform BOM (default for projects generated), add the Quarkus Langchain4J BOM and all dependency versions will align:

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>${quarkus.platform.artifact-id}</artifactId>
                <version>${quarkus.platform.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>${quarkus.platform.group-id}</groupId>
                <artifactId>quarkus-langchain4j-bom</artifactId> (1)
                <version>${quarkus.platform.version}</version> (2)
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
      <dependency>
        <groupId>io.quarkiverse.langchain4j</groupId>
        <artifactId>quarkus-langchain4j-watsonx</artifactId>
        (3)
      </dependency>
    </dependencies>
1 In your dependencyManagement section, add the quarkus-langchain4j-bom
2 Inherit the version from your platform version
3 Voilà, no need for version alignment anymore

If no other extension is installed, AI Services will automatically use this provider.

Chat Model

IBM watsonx.ai provides a variety of foundation models for text generation, chat-based interactions, and instruction-following tasks. These include both IBM-built models and third-party / community models. Quarkus integrates the LangChain4j WatsonxChatModel, exposing it as ChatModel / StreamingChatModel bean.

See the full model catalog:

Configuration

Configure the chat model in your application.properties:

# Base Watsonx configuration
quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}

# Chat model
quarkus.langchain4j.watsonx.chat-model.model-name=ibm/granite-4-h-small

# Optional generation parameters
quarkus.langchain4j.watsonx.chat-model.max-output-tokens=0
quarkus.langchain4j.watsonx.chat-model.temperature=0.2

If a chat model is configured, Quarkus automatically registers a ChatModel / StreamingChatModel bean.

Choosing the chat backend

watsonx.ai can serve a chat request in three different ways, each one with its own configuration namespace:

Namespace watsonx.ai API Selected when

quarkus.langchain4j.watsonx.chat-model

Foundation models (/ml/v1/text/chat)

no other namespace is configured (default)

quarkus.langchain4j.watsonx.deployment-chat-model

A model deployed in watsonx.ai (/ml/v1/deployments/{deployment_id}/text/chat)

deployment-chat-model.deployment-id is set

quarkus.langchain4j.watsonx.gateway-chat-model

Model Gateway (/ml/gateway/v1/chat/completions)

gateway-chat-model.model-name is set

Only one backend can be used per configuration, so setting both deployment-chat-model.deployment-id and gateway-chat-model.model-name fails at startup. To use more than one backend in the same application, declare each of them under its own named configuration (quarkus.langchain4j.watsonx."<name>".*) and select it with the @ModelName qualifier.

Using a Deployment

To target a model deployed in watsonx.ai, set its deployment-id. Neither project-id nor space-id is required, and chat-model.model-name is not used.

quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}

# Use a deployed model instead of a foundation model
quarkus.langchain4j.watsonx.deployment-chat-model.deployment-id=${DEPLOYMENT_ID}
quarkus.langchain4j.watsonx.deployment-chat-model supports the same generation parameters as quarkus.langchain4j.watsonx.chat-model, with the exception of model-name, project-id and space-id.

Using the Model Gateway

The watsonx.ai Model Gateway exposes an OpenAI-compatible chat endpoint that can route requests to models hosted by multiple providers (for example OpenAI, Anthropic, Mistral, or any third-party provider registered in the gateway) behind a single watsonx.ai entry point. To use it, set gateway-chat-model.model-name. Neither project-id nor space-id is required, and chat-model.model-name is not used.

quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}

# Route the requests through the Model Gateway
quarkus.langchain4j.watsonx.gateway-chat-model.model-name=gpt-4o-mini
The gateway must be configured by an administrator before use. The value of model-name must be a model identifier that is already registered in the gateway, which means the alias defined by the administrator or, when there is no alias, the provider-side model identifier. The model catalog of the gateway returns the identifiers that can be used.

Besides the generation parameters shared with chat-model, the gateway supports a set of provider-agnostic routing options:

# Latency tier used to serve the request: auto, default, flex or priority
quarkus.langchain4j.watsonx.gateway-chat-model.service-tier=default

# Reasoning budget for reasoning models: low, medium or high
quarkus.langchain4j.watsonx.gateway-chat-model.reasoning-effort=low

# Semantic cache (honored on non-streaming requests only)
quarkus.langchain4j.watsonx.gateway-chat-model.cache.enabled=true
quarkus.langchain4j.watsonx.gateway-chat-model.cache.threshold=0.95

# Output types the model is asked to generate
quarkus.langchain4j.watsonx.gateway-chat-model.modalities=text

# Whether the provider should persist the request/response
quarkus.langchain4j.watsonx.gateway-chat-model.store=false

# Whether the model is allowed to run tool calls in parallel
quarkus.langchain4j.watsonx.gateway-chat-model.parallel-tool-calls=true

# Stable identifier of the end user, used by the provider to detect abuse
quarkus.langchain4j.watsonx.gateway-chat-model.user=user-1234

# Arbitrary key/value pairs attached to the request and returned with the response
quarkus.langchain4j.watsonx.gateway-chat-model.metadata.my-key=my-value
The foundation-model only parameters (guided-choice, guided-grammar, guided-regex, length-penalty, repetition-penalty and thinking) are not supported by the Model Gateway and are therefore not available under quarkus.langchain4j.watsonx.gateway-chat-model.

Overriding the routing options per request

The gateway parameters can also be set on a single request through WatsonxGatewayChatRequestParameters.

ChatRequest request = ChatRequest.builder()
    .messages(UserMessage.from("Solve this step by step."))
    .parameters(WatsonxGatewayChatRequestParameters.builder()
        .serviceTier(ServiceTier.FLEX)
        .reasoningEffort(ReasoningEffort.HIGH)
        .build())
    .build();

String answer = chatModel.chat(request).aiMessage().text();
Each watsonx.ai chat service has its own ChatRequestParameters implementation, exposing the parameters that service accepts and nothing else. WatsonxChatRequestParameters covers the foundation-model and deployment backends, WatsonxGatewayChatRequestParameters covers the Model Gateway. Passing the parameters of one service to the other only contributes what DefaultChatRequestParameters covers (modelName, temperature, topP, maxOutputTokens, …​), and every watsonx.ai-specific parameter they carry is silently ignored. Always use the class matching the configured backend.

Response metadata

The metadata of a gateway response is a WatsonxChatResponseMetadata exposing three fields that only the Model Gateway populates.

ChatResponse response = chatModel.chat(request);
var metadata = (WatsonxChatResponseMetadata) response.metadata();

metadata.getServiceTier();       // service tier that served the request
metadata.getSystemFingerprint(); // provider system fingerprint
metadata.getCached();            // whether the response was served from the cache
The Model Gateway does not return the resolved model identifier, so response.metadata().modelName() is null on this backend. The model that was requested is the one configured in gateway-chat-model.model-name.

Structured Outputs

Setting response-format to json_schema declares that the model supports the RESPONSE_FORMAT_JSON_SCHEMA capability. An AI service then derives a JSON Schema from the return type of the method and asks the model to return a response that follows it.

quarkus.langchain4j.watsonx.chat-model.response-format=json_schema

The schema is sent in strict mode by default: the model is constrained to return a response that matches it exactly. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set strict-json-schema to false to let the model treat the schema as a hint instead of a constraint:

quarkus.langchain4j.watsonx.chat-model.strict-json-schema=false
response-format and strict-json-schema are available on the three chat backends (chat-model, deployment-chat-model and gateway-chat-model), and the strict mode is the default on all of them.

Injection

@Inject
ChatModel chatModel;

@Inject
StreamingChatModel chatModel;

Enabling Thinking / Reasoning Output

Some foundation models can include internal reasoning (also referred to as thinking) steps as part of their responses. Depending on the model, this reasoning may be embedded in the same text as the final response, or returned separately in a dedicated field from watsonx.ai.

To correctly enable and capture this behavior in Quarkus, you must configure the chat model with either thinking.tags (for ExtractionTags) or thinking.effort / thinking (for ThinkingEffort or boolean flag) in your application.properties. This ensures that LangChain4j can automatically extract the reasoning and response content from the model output.

Models that return reasoning and response together

Use ExtractionTags when the model outputs reasoning and response in the same text string. Configure the exact opening and closing delimiters used by the model.

Example for ibm/granite-3-3-8b-instruct

quarkus.langchain4j.watsonx.chat-model.model-name=ibm/granite-3-3-8b-instruct
quarkus.langchain4j.watsonx.chat-model.thinking.tags.think.opening=<think>
quarkus.langchain4j.watsonx.chat-model.thinking.tags.think.closing=</think>
quarkus.langchain4j.watsonx.chat-model.thinking.tags.response.opening=<response>
quarkus.langchain4j.watsonx.chat-model.thinking.tags.response.closing=</response>

Example for google/gemma-4-31b-it

quarkus.langchain4j.watsonx.chat-model.model-name=google/gemma-4-31b-it
quarkus.langchain4j.watsonx.chat-model.thinking.tags.think.opening=<|channel>thought\n
quarkus.langchain4j.watsonx.chat-model.thinking.tags.think.closing=<channel|>

Behavior

  • If both think and response delimiters are specified, they are used to extract reasoning and response segments respectively.

  • If only think delimiters are specified, everything outside that delimiter pair is treated as the response.

@Inject
ChatModel thinkingChatModel;

var chatResponse = thinkingChatModel.chat(UserMessage.from("Why is the sky blue?"));
System.out.println(chatResponse.aiMessage().thinking());
System.out.println(chatResponse.aiMessage().text());

Models that return reasoning and response separately

For models that already return reasoning and response as separate fields, use the thinking.effort property to control how much reasoning the model applies during generation, or enable it using the boolean flag.

# Example configuration for openai/gpt-oss-120b
quarkus.langchain4j.watsonx.chat-model.model-name=openai/gpt-oss-120b
quarkus.langchain4j.watsonx.chat-model.thinking.effort=HIGH

Streaming Example

@Inject
StreamingChatModel streamingChatModel;

List<ChatMessage> messages = List.of(UserMessage.from("Why is the sky blue?"));

ChatRequest chatRequest = ChatRequest.builder()
    .messages(messages)
    .build();

streamingChatModel.chat(chatRequest, new StreamingChatResponseHandler() {

    @Override
    public void onPartialResponse(String partialResponse) {
        System.out.println("Partial: " + partialResponse);
    }

    @Override
    public void onPartialThinking(PartialThinking partialThinking) {
        System.out.println("Thinking: " + partialThinking.content());
    }

    @Override
    public void onCompleteResponse(ChatResponse completeResponse) {
        System.out.println("Complete: " + completeResponse);
    }

    @Override
    public void onError(Throwable error) {
        error.printStackTrace();
    }
});
  • Ensure that the selected model supports reasoning output.

  • Use thinking.tags for models that embed reasoning and response in a single text string, specifying the full opening and closing delimiters explicitly.

  • Use thinking.effort or thinking=true for models that already separate reasoning and response automatically.

Embedding Model

IBM watsonx.ai provides multiple embedding models for converting text into vector representations suitable for semantic search, RAG pipelines, similarity comparison, and vector database integrations.

Quarkus integrates the LangChain4j WatsonxEmbeddingModel, exposing it as EmbeddingModel bean.

A list of supported embedding models can be found here:

Configuration

Configure the embedding model by specifying its model name in application.properties:

# Base Watsonx configuration
quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}

# Embedding model configuration
quarkus.langchain4j.watsonx.embedding-model.model-name=ibm/slate-125m-english-rtrvr

If an embedding model is configured, Quarkus will automatically create and register a EmbeddingModel bean.

Injection

@Inject
EmbeddingModel embeddingModel;

Usage

Generating an embedding for a single text:

var response = embeddingModel.embed("Hello Watsonx!");

assertNotNull(response);
var embedding = response.content();

System.out.println("Embedding size: " + embedding.vector().length());

Generating embeddings for multiple text segments:

var embeddings = embeddingModel.embedAll(
    List.of(
        TextSegment.from("First document"),
        TextSegment.from("Second document")
    )
);

Scoring Model

IBM watsonx.ai provides scoring (reranking) models that evaluate the relevance between a query and a piece of text. Quarkus integrates the LangChain4j WatsonxScoringModel, exposing it as ScoringModel implementation.

Scoring models are especially useful for RAG pipelines, document ranking, and semantic relevance evaluation.

A list of supported scoring/reranker models is available here:

Configuration

Configure the model by specifying its name in application.properties:

# Base Watsonx configuration
quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}

# Scoring model configuration
quarkus.langchain4j.watsonx.scoring-model.model-name=cross-encoder/ms-marco-minilm-l-12-v2

If an score model is configured, Quarkus will automatically create and register a ScoringModel bean.

Injection

@Inject
ScoringModel scoringModel;

Usage

You can score a single text against a query:

var response = scoringModel.score("Rerank this!", "Test to rerank 1");

assertNotNull(response);
assertNotNull(response.content());

double score = response.content();
System.out.println("Score: " + score);

Or score multiple documents at once:

var scores = scoringModel.scoreAll(
    List.of(
        TextSegment.from("Document A"),
        TextSegment.from("Document B")
    ),
    "User query"
);

System.out.println(scores); // list of relevance scores

Moderation Model

IBM watsonx.ai provides moderation capabilities through multiple detectors that can identify unsafe, sensitive, or policy-violating content. Quarkus integrates the LangChain4j WatsonxModerationModel, exposing each detector type as a dedicated configuration group.

Supported detector types include:

  • PII - Detects Personally Identifiable Information

  • HAP - Detects hate, abuse, or profanity

  • Granite Guardian - Detects harmful or risky content

Each detector can be enabled individually.

Configuration

Enable detectors in application.properties using their dedicated flags:

# Base Watsonx configuration
quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}

# Enable specific moderation detectors
quarkus.langchain4j.watsonx.moderation-model.hap.enabled=true
quarkus.langchain4j.watsonx.moderation-model.pii.enabled=true
quarkus.langchain4j.watsonx.moderation-model.granite-guardian.enabled=true

Each detector configuration group may also expose additional settings depending on its capabilities. If an score model is configured, Quarkus will automatically create and register a ModerationModel bean.

Injection

@Inject
ModerationModel moderationModel;

Usage

var response = moderationModel.moderate("Some text to analyze");

boolean flagged = response.content().flagged();
Map<String, Object> metadata = response.metadata();

System.out.println("Flagged? " + flagged);
System.out.println("Metadata: " + metadata);

Metadata

A moderation response includes metadata describing the detection:

Key Description

detection

The assigned label for the detected content

detection_type

Detector that triggered the flag

start

Start index of the detected segment

end

End index of the detected segment

score

Confidence score

Example:

System.out.println(metadata.get("detection_type"));
System.out.println(metadata.get("score"));

Text Extraction

The TextExtraction feature enables developers to extract text from high-value business documents stored in IBM Cloud Object Storage. Extracted text can be used for AI processing, key information identification, or further document analysis.

The API supports text extraction from the following file types:

  • PDF

  • GIF

  • JPG

  • PNG

  • TIFF

  • BMP

  • DOC

  • DOCX

  • HTML

  • JFIF

  • PPT

  • PPTX

The extracted text can be output in the following formats:

  • JSON

  • MARKDOWN

  • HTML

  • PLAIN_TEXT

  • PAGE_IMAGES

Configuration

To enable TextExtraction in your application, configure the following properties:

quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}
quarkus.langchain4j.watsonx.text-extraction.cos-url=<base-url>
quarkus.langchain4j.watsonx.text-extraction.document-reference.connection=<connection-id>
quarkus.langchain4j.watsonx.text-extraction.document-reference.bucket-name=<bucket-name>
quarkus.langchain4j.watsonx.text-extraction.results-reference.connection=<connection-id>
quarkus.langchain4j.watsonx.text-extraction.results-reference.bucket-name=<bucket-name>
  • cos-url: The endpoint where the IBM Cloud Object Storage instance is deployed. To find the appropriate value, refer to the IBM Cloud Object Storage endpoint table.

  • document-reference.connection: The connection asset ID containing credentials to access the source storage.

  • document-reference.bucket-name: The bucket where documents to be processed will be uploaded.

  • results-reference.connection: The connection asset ID containing credentials to access the output storage.

  • results-reference.bucket-name: The bucket where extracted text documents will be saved as new files.

The document reference properties define the source storage for input and uloaded files, while the results reference properties specify where the extracted content is stored. Both can refer to the same bucket or different ones.

For more information on how to get the connection parameter for the document-reference and results-reference you can refer to the documentation at this link.

Using Text Extraction

The TextExtraction class provides multiple methods for extracting text from documents. You can either extract text from an existing file in IBM Cloud Object Storage or upload a file and extract its content. To use TextExtraction, you need to inject an instance into your application. If multiple configurations are defined, you can specify the appropriate one using the @ModelName qualifier.

@Inject
TextExtractionService textExtraction;

@Inject
@ModelName("custom")
TextExtractionService customTextExtraction;

You can start the extraction process in two ways.

First, if the document is already stored in IBM Cloud Object Storage, you can initiate the extraction by using the following method:

TextExtractionResponse response = textExtraction.startExtraction("path/to/document");
String id = response.metadata().id();

Alternatively, if you’re working with a local file, you can upload it and start the extraction process with:

File file = new File("path/to/document");
File response = textExtraction.uploadAndStartExtraction(file);
String id = response.metadata().id();

After starting the extraction, you can check its status by calling:

TextExtractionResponse response = textExtraction.fetchExtractionRequest(extractionId);
String result = response.entity().results().status();

If you need to extract and retrieve the text immediately, you have two options.

You can either extract text from an existing file directly:

String extractedText = textExtraction.extractAndFetch("path/to/document");

Or upload the file and retrieve the extracted text immediately:

File file = new File("path/to/document");
String extractedText = textExtraction.uploadExtractAndFetch(file);

All extraction methods can accept a Parameters object to customize the behavior of the text extraction request.

The Parameters object allows fine-grained control over the extraction process.

var parameters = TextExtractionParameters.builder()
        .removeOutputFile(true)
        .removeUploadedFile(true)
        .requestedOutputs(MD)
        .mode(Mode.HIGH_QUALITY)
        .autoRotationCorrection(false)
        .outputDpi(16)
        .build()

File file = new File("path/to/document.pdf");
String extractedText = textExtraction.uploadExtractAndFetch(file, parameters));

Text Classification

The TextClassification feature enables you to classify text in your documents to identify whether the data in your file matches the key-value pair format in schema definitions for various document types.

By pre-processing the document, you can quickly verify whether a document is classified into one of the pre-defined schemas or a custom schema without performing key-value pair extraction, which can be a longer, resource-intensive process. You can then decide which schema to use to correctly extract text into fields in a key-value pair format.

The API supports text classification from the following file types:

  • BMP

  • DOC

  • DOCX

  • GIF

  • HTML

  • JFIF

  • JPG

  • MARKDOWN

  • PDF

  • PNG

  • PPT

  • PPTX

  • TIFF

  • XLSX

Configuration

To enable TextClassification in your application, configure the following properties:

quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}
quarkus.langchain4j.watsonx.text-classification.cos-url=<base-url>
quarkus.langchain4j.watsonx.text-classification.document-reference.connection=<connection-id>
quarkus.langchain4j.watsonx.text-classification.document-reference.bucket-name=<bucket-name>
  • cos-url: The endpoint where the IBM Cloud Object Storage instance is deployed. To find the appropriate value, refer to the IBM Cloud Object Storage endpoint table.

  • document-reference.connection: The connection asset ID containing credentials to access the source storage.

  • document-reference.bucket-name: The bucket where documents to be processed will be uploaded (or are already stored).

For more information on how to get the connection parameter for the document-reference you can refer to the documentation at this link.

Using Text Classification

The TextClassificationService class provides multiple methods for classifying documents. You can either classify text from an existing file in IBM Cloud Object Storage or upload a file and classify its content. To use TextClassificationService, you need to inject an instance into your application. If multiple configurations are defined, you can specify the appropriate one using the @ModelName qualifier.

@Inject
TextClassificationService classificationService;

@Inject
@ModelName("custom")
TextClassificationService customClassificationService;

You can start the classification process in two ways.

First, if the document is already stored in IBM Cloud Object Storage, you can initiate the classification by using the following method:

TextClassificationResponse response = classificationService.startClassification("path/to/document");
String id = response.metadata().id();

Alternatively, if you’re working with a local file, you can upload it and start the classification process with:

File file = new File("path/to/document");
TextClassificationResponse response = classificationService.uploadAndStartClassification(file);
String id = response.metadata().id();

After starting the classification, you can check its status by calling:

TextClassificationResponse response = classificationService.fetchClassificationRequest(classificationId);
String result = response.entity().results().status();

If you need to classify and retrieve the results immediately, you have two options.

You can either classify an existing file directly:

ClassificationResult result = classificationService.classifyAndFetch("path/to/document");

Or upload the file and retrieve the classification result immediately:

File file = new File("path/to/document");
ClassificationResult result = classificationService.uploadClassifyAndFetch(file);

All classification methods can accept a TextClassificationParameters object to customize the behavior of the request.

The TextClassificationParameters object allows fine-grained control over the classification process, including Classification Modes, OCR settings, and Semantic Configuration.

var parameters = TextClassificationParameters.builder()
        .classificationMode(ClassificationMode.EXACT)
        .languages(Language.ENGLISH, Language.FRENCH)
        .ocrMode(OcrMode.AUTO)
        .autoRotationCorrection(true)
        .removeUploadedFile(true)
        .build();

File file = new File("path/to/document.pdf");
ClassificationResult result = classificationService.uploadClassifyAndFetch(file, parameters));

Semantic Configuration

You can provide a TextClassificationSemanticConfig to the parameters. This allows you to define custom schemas, enabling the service to identify specific document types based on the presence of key-value pair fields you define.

The following example shows how to configure the service to classify a document as a specific "Invoice" type:

// 1. Define the fields expected in the document
var fields = KvpFields.builder()
    .add("invoice_date", KvpField.of("The date when the invoice was issued.", "2024-07-10"))
    .add("invoice_number", KvpField.of("The unique number identifying the invoice.", "INV-2024-001"))
    .add("total_amount", KvpField.of("The total amount to be paid.", "1250.50"))
    .build();

// 2. Define the Schema using the fields
var mySchema = Schema.builder()
    .documentDescription("A vendor-issued invoice listing purchased items, prices, and payment information.")
    .documentType("Invoice")
    .fields(fields)
    .build();

// 3. Create the Semantic Configuration
var semanticConfig = TextClassificationSemanticConfig.builder()
    .schemasMergeStrategy(SchemaMergeStrategy.REPLACE)
    .schemas(mySchema)
    .build();

// 4. Pass the configuration to the parameters
var parameters = TextClassificationParameters.builder()
    .languages(Language.ENGLISH)
    .semanticConfig(semanticConfig)
    .build();

ClassificationResult result = classificationService.uploadClassifyAndFetch(file, parameters);

Managing Requests and Files

The service also provides utility methods to manage the lifecycle of your requests and files:

// Delete a classification request history
classificationService.deleteRequest(requestId,
    TextClassificationDeleteParameters.builder().hardDelete(true).build());

// Delete a file from the bucket
classificationService.deleteFile("bucket-name", "filename.pdf");

Schema Services

A Schema describes, in key-value pair form, the information to extract from a document. It is the input of the semantic configuration used by Text Extraction and Text Classification. Instead of writing it by hand, the Schema services let watsonx.ai generate, refine and combine schemas for you:

Service CDI bean What it does

Create schema

CreateSchemaService

Automatically generates a schema from a document stored in (or uploaded to) IBM Cloud Object Storage.

Improve schema

ImproveSchemaService

Refines and enriches an existing schema with better field descriptions, missing fields and a more comprehensive document description.

Merge schema

MergeSchemaService

Combines multiple schemas into a single unified schema covering all the input document types.

Cluster schema

ClusterSchemaService

Groups a set of document schemas into clusters of semantically similar documents.

The main benefit of this approach is that no schema has to be written by hand, because a representative sample document is enough to obtain a schema that can then be reused, unchanged, to process every document of the same type.

Configuration

ImproveSchemaService, MergeSchemaService and ClusterSchemaService only need the common watsonx.ai properties:

quarkus.langchain4j.watsonx.base-url=${BASE_URL}
quarkus.langchain4j.watsonx.api-key=${API_KEY}
quarkus.langchain4j.watsonx.project-id=${PROJECT_ID}

CreateSchemaService reads its input document from IBM Cloud Object Storage, so it additionally requires:

quarkus.langchain4j.watsonx.schema.create.cos-url=<base-url>
quarkus.langchain4j.watsonx.schema.create.document-reference.connection=<connection-id>
quarkus.langchain4j.watsonx.schema.create.document-reference.bucket-name=<bucket-name>
  • cos-url: The endpoint where the IBM Cloud Object Storage instance is deployed. To find the appropriate value, refer to the IBM Cloud Object Storage endpoint table.

  • document-reference.connection: The connection asset ID containing credentials to access the source storage.

  • document-reference.bucket-name: The bucket where documents to be processed will be uploaded (or are already stored).

These three properties are only validated when CreateSchemaService is actually injected. Injecting it without them fails at startup with a message listing every missing property.

Injection

Each service is exposed as an @ApplicationScoped bean. If multiple configurations are defined, select the appropriate one with the @ModelName qualifier.

@Inject
CreateSchemaService createSchemaService;

@Inject
ImproveSchemaService improveSchemaService;

@Inject
MergeSchemaService mergeSchemaService;

@Inject
ClusterSchemaService clusterSchemaService;

@Inject
@ModelName("custom")
CreateSchemaService customCreateSchemaService;

Creating a Schema

The simplest way to obtain a schema is to upload a local file and wait for the result in a single call:

File file = new File("path/to/invoice.pdf");
CreateSchemaResult result = createSchemaService.uploadCreateSchemaAndFetch(file);

Schema schema = result.schema();
System.out.println(schema.documentType());        // Invoice
System.out.println(schema.documentDescription()); // A vendor-issued invoice listing purchased items, ...
System.out.println(schema.fields());              // The generated key-value pair fields

If the document is already stored in IBM Cloud Object Storage, the same result can be obtained from its path in the bucket:

CreateSchemaResult result = createSchemaService.createSchemaAndFetch("path/to/invoice.pdf");

Both methods are synchronous and poll the request until it completes. To submit it and poll it yourself, use the start* methods and fetchRequest:

// The document is already in Cloud Object Storage
CreateSchemaResponse response = createSchemaService.startCreateSchema("path/to/invoice.pdf");

// Or upload it first
CreateSchemaResponse response = createSchemaService.uploadAndStartCreateSchema(new File("path/to/invoice.pdf"));

String id = response.metadata().id();

// Later on
CreateSchemaResult result = createSchemaService.fetchRequest(id).entity().results();
String status = result.status(); // submitted, running, completed or failed

All the methods above accept a CreateSchemaParameters object to customize the request:

var parameters = CreateSchemaParameters.builder()
    .mode(Mode.HIGH_QUALITY)
    .languages(Language.ENGLISH)
    .ocrMode(OcrMode.AUTO)
    .autoRotationCorrection(true)
    .additionalPromptInstructions("Focus on the payment section.")
    .enableGrounding(true)
    .maxPagesToProcess(5)
    .semanticConfig(CreateSchemaSemanticConfig.builder()
        .defaultModelName("mistralai/mistral-medium-2505")
        .build())
    .removeUploadedFile(true)
    .timeout(Duration.ofMinutes(10))
    .build();

CreateSchemaResult result = createSchemaService.uploadCreateSchemaAndFetch(file, parameters);
  • mode: Mode.STANDARD for faster processing, Mode.HIGH_QUALITY for a slower but more accurate field detection.

  • ocrMode: OcrMode.DISABLED (the default, the document must contain native text), ENABLED, FORCED or AUTO to let the service decide.

  • additionalPromptInstructions: Free-form instructions used to guide the generation of the schema.

  • maxPagesToProcess: Maximum number of pages analyzed to build the schema.

  • semanticConfig: Overrides the foundation model used to generate the schema (mistral-small-3-1-24b-instruct-2503 by default).

  • removeUploadedFile: Deletes the uploaded file from the bucket once the schema has been created.

  • timeout: Overrides the timeout of this request.

removeUploadedFile and timeout are only honored by the synchronous methods (createSchemaAndFetch and uploadCreateSchemaAndFetch). When using startCreateSchema or uploadAndStartCreateSchema, delete the file yourself with deleteFile once the request has completed.

Grounding Hints

When enableGrounding(true) is set, the result also contains, for each generated field, the page and the normalized bounding box where the value was found:

var parameters = CreateSchemaParameters.builder()
    .mode(Mode.HIGH_QUALITY)
    .enableGrounding(true)
    .build();

CreateSchemaResult result = createSchemaService.uploadCreateSchemaAndFetch(file, parameters);

GroundingHints hints = result.groundingHints();
List<Double> bbox = hints.bbox("invoice_number"); // [x1, y1, x2, y2], from top-left to bottom-right
Integer page = hints.pageNumber("invoice_number");
Mode.HIGH_QUALITY is required to obtain the grounding hints. With Mode.STANDARD the request still succeeds, but result.groundingHints() contains no field.

Improving a Schema

ImproveSchemaService takes an existing schema and returns an enriched version of it, with more accurate field and document descriptions:

Schema schema = Schema.builder()
    .documentType("Passport")
    .documentDescription("Passport document")
    .fields(KvpFields.builder()
        .add("name", KvpField.of("name of the user", "Alan"))
        .add("lastname", KvpField.of("lastname of the user", "Wake"))
        .build())
    .build();

Schema improved = improveSchemaService.improveSchemaAndFetch(schema).schema();

System.out.println(improved.documentDescription());
// A Passport document serves as an official government-issued identification for
// international travel, verifying the holder's identity and nationality...

The additionalPromptInstructions of the input schema are used to guide the improvement and are preserved in the result:

Schema schema = Schema.builder()
    .documentType("Invoice")
    .documentDescription("Invoice document")
    .additionalPromptInstructions("Focus on European VAT formats")
    .fields(KvpFields.builder()
        .add("invoice_number", KvpField.of("Invoice number", "INV-001"))
        .build())
    .build();

Schema improved = improveSchemaService.improveSchemaAndFetch(schema).schema();
System.out.println(improved.additionalPromptInstructions()); // Focus on European VAT formats

As for the creation, an asynchronous variant and the polling method are available, and an ImproveSchemaParameters object can be passed to override the foundation model, the timeout or the target project:

ImproveSchemaResponse response = improveSchemaService.startImproveSchema(schema);
String status = improveSchemaService.fetchRequest(response.metadata().id()).entity().results().status();

Merging Schemas

MergeSchemaService combines multiple schemas into a single one that covers all of them, unifying the fields and producing a description encompassing every input document type:

List<Schema> schemas = List.of(
    Schema.builder()
        .documentType("Passport")
        .documentDescription("Passport document")
        .fields(KvpFields.builder()
            .add("name", KvpField.of("Holder's name", "John"))
            .build())
        .build(),
    Schema.builder()
        .documentType("National ID Card")
        .documentDescription("National ID Card document")
        .fields(KvpFields.builder()
            .add("id", KvpField.of("ID number", "ABC123"))
            .build())
        .build());

Schema merged = mergeSchemaService.mergeSchemaAndFetch(schemas).schema();

System.out.println(merged.documentType()); // Identification Document

The asynchronous variant behaves like the other services:

MergeSchemaResponse response = mergeSchemaService.startMergeSchema(schemas);
String status = mergeSchemaService.fetchRequest(response.metadata().id()).entity().results().status();

Clustering Schemas

ClusterSchemaService groups a set of document schemas into clusters of semantically similar documents. Every input schema is paired with the name of the document it describes:

List<ClusterSchemas> schemas = List.of(
    new ClusterSchemas("passport.pdf", Schema.builder()
        .documentType("Passport")
        .documentDescription("Passport document")
        .build()),
    new ClusterSchemas("id-card.pdf", Schema.builder()
        .documentType("National ID Card")
        .documentDescription("National ID Card document")
        .build()),
    new ClusterSchemas("invoice.pdf", Schema.builder()
        .documentType("Invoice")
        .documentDescription("Invoice document")
        .build()));

List<List<ClusterSchemas>> clusters = clusterSchemaService.clusterSchemaAndFetch(schemas);

// The two identification documents are grouped together, the invoice is alone in its own cluster
clusters.forEach(cluster -> System.out.println(cluster.stream().map(ClusterSchemas::documentName).toList()));
// [passport.pdf, id-card.pdf]
// [invoice.pdf]

Each cluster can then be collapsed into a single schema with MergeSchemaService, obtaining one schema per group of similar documents.

A ClusterSchemaParameters object can be passed to change the foundation model used to compute the clusters or to target a different project or space:

var parameters = ClusterSchemaParameters.builder()
    .semanticConfig(ClusterSchemaSemanticConfig.builder()
        .defaultModelName("ibm/granite-4-h-small")
        .build())
    .build();

List<List<ClusterSchemas>> clusters = clusterSchemaService.clusterSchemaAndFetch(parameters, schemas);

The asynchronous variant behaves like the other services:

ClusterSchemaResponse response = clusterSchemaService.startClusterSchema(schemas);
String status = clusterSchemaService.fetchRequest(response.metadata().id()).entity().results().status();

Using a Generated Schema

A generated schema is a regular Schema, so it can be passed straight to the semantic configuration of Text Extraction or Text Classification:

@Inject
CreateSchemaService createSchemaService;

@Inject
TextExtractionService textExtractionService;

public String extract(File document) {

    // 1. Generate the schema from a representative sample document
    Schema schema = createSchemaService.uploadCreateSchemaAndFetch(document,
        CreateSchemaParameters.builder()
            .mode(Mode.HIGH_QUALITY)
            .languages(Language.ENGLISH)
            .removeUploadedFile(true)
            .build())
        .schema();

    // 2. Use it to extract the key-value pairs of every document of the same type
    var parameters = TextExtractionParameters.builder()
        .languages(Language.ENGLISH)
        .mode(Mode.HIGH_QUALITY)
        .kvpMode(KvpMode.GENERIC_WITH_SEMANTIC)
        .semanticConfig(TextExtractionSemanticConfig.builder()
            .schemas(schema)
            .build())
        .removeUploadedFile(true)
        .build();

    return textExtractionService.uploadExtractAndFetch(document, parameters);
}
Generate the schema once, from a document containing all the expected fields, then store it and reuse it for the batch processing of the other documents. Enabling grounding during the generation makes it easy to verify that every field was located where it was expected.

Managing Requests and Files

All three services can delete the history of a request. Passing hardDelete(true) also removes its metadata. deleteRequest returns false when the request does not exist.

createSchemaService.deleteRequest(requestId,
    CreateSchemaDeleteParameters.builder().hardDelete(true).build());

improveSchemaService.deleteRequest(requestId);
mergeSchemaService.deleteRequest(requestId);

CreateSchemaService can also upload and delete files in the configured bucket:

createSchemaService.uploadFile(new File("path/to/document.pdf"));
createSchemaService.deleteFile("bucket-name", "document.pdf");

For the complete list of parameters and result fields, see the watsonx.ai Schema API reference.

Configuration

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

Whether the model should be enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_ENABLED

boolean

true

Whether the embedding model should be enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_EMBEDDING_MODEL_ENABLED

boolean

true

Whether the scoring model should be enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCORING_MODEL_ENABLED

boolean

true

Whether the moderation model should be enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_ENABLED

boolean

true

Specifies the base URL of the watsonx.ai API.

A list of all available URLs is provided in the IBM Watsonx.ai documentation at the this link.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BASE_URL

string

IBM Cloud API key.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_API_KEY

string

Timeout for watsonx.ai calls.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TIMEOUT

Duration 

60s

The version date for the API of the form YYYY-MM-DD.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_VERSION

string

The space that contains the resource.

Either space_id or project_id has to be given.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SPACE_ID

string

The project that contains the resource.

Either space_id or project_id has to be given.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_PROJECT_ID

string

Whether the watsonx.ai client should log requests.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_LOG_REQUESTS

boolean

false

Whether the watsonx.ai client should log responses.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_LOG_REQUESTS_CURL

boolean

false

Whether to enable the integration. Defaults to true, which means requests are made to the watsonx.ai provider. Set to false to disable all requests.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_ENABLE_INTEGRATION

boolean

true

Base URL of the IAM Authentication API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_IAM_BASE_URL

URI

Timeout for IAM authentication calls.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_IAM_TIMEOUT

Duration 

10s

Grant type for the IAM Authentication API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_IAM_GRANT_TYPE

string

Base URL of the Cloud Object Storage API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_COS_URL

string

required

The id of the connection asset that contains the credentials required to access the data.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_DOCUMENT_REFERENCE_CONNECTION

string

required

The name of the bucket containing the input document.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_DOCUMENT_REFERENCE_BUCKET_NAME

string

required

The id of the connection asset used to store the extracted results.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_RESULTS_REFERENCE_CONNECTION

string

required

The name of the bucket where the output files will be written.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_RESULTS_REFERENCE_BUCKET_NAME

string

required

Whether text extraction requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_LOG_REQUESTS

boolean

false

Whether text extraction responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_EXTRACTION_LOG_REQUESTS_CURL

boolean

false

Base URL of the Cloud Object Storage API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_CLASSIFICATION_COS_URL

string

required

The id of the connection asset that contains the credentials required to access the data.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_CLASSIFICATION_DOCUMENT_REFERENCE_CONNECTION

string

required

The name of the bucket containing the input document.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_CLASSIFICATION_DOCUMENT_REFERENCE_BUCKET_NAME

string

required

Whether text extraction requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_CLASSIFICATION_LOG_REQUESTS

boolean

false

Whether text extraction responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_CLASSIFICATION_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_TEXT_CLASSIFICATION_LOG_REQUESTS_CURL

boolean

false

Base URL of the Cloud Object Storage API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CREATE_COS_URL

string

required

The id of the connection asset that contains the credentials required to access the data.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CREATE_DOCUMENT_REFERENCE_CONNECTION

string

required

The name of the bucket containing the input document.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CREATE_DOCUMENT_REFERENCE_BUCKET_NAME

string

required

Whether create schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CREATE_LOG_REQUESTS

boolean

false

Whether create schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CREATE_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CREATE_LOG_REQUESTS_CURL

boolean

false

Whether improve schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_IMPROVE_LOG_REQUESTS

boolean

false

Whether improve schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_IMPROVE_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_IMPROVE_LOG_REQUESTS_CURL

boolean

false

Whether merge schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_MERGE_LOG_REQUESTS

boolean

false

Whether merge schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_MERGE_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_MERGE_LOG_REQUESTS_CURL

boolean

false

Whether cluster schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CLUSTER_LOG_REQUESTS

boolean

false

Whether cluster schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CLUSTER_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCHEMA_CLUSTER_LOG_REQUESTS_CURL

boolean

false

Specifies how the model should choose which tool to call during a request.

This value can be:

  • auto: The model decides whether and which tool to call automatically.

  • required: The model must call one of the available tools.

If toolChoiceName is set, this value is ignored.

Setting this value influences the tool-calling behavior of the model when no specific tool is required.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_TOOL_CHOICE

auto, required, none

Specifies the name of a specific tool that the model must call.

When set, the model will be forced to call the specified tool. The name must exactly match one of the available tools defined for the service.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_TOOL_CHOICE_NAME

string

Positive values penalize new tokens based on their existing frequency in the generated text, reducing the likelihood of the model repeating the same lines verbatim.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_FREQUENCY_PENALTY

double

Specifies whether to return the log probabilities of the output tokens.

If set to true, the response will include the log probability of each output token in the content of the message.

The parameter is sent to the model only when it is set.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_LOGPROBS

boolean

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. The option logprobs must be set to true if this parameter is used.

Possible values: 0 ≤ value ≤ 20

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_TOP_LOGPROBS

int

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length. Set to 0 for the model’s configured max generated tokens.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_MAX_OUTPUT_TOKENS

int

1024

Applies a penalty to new tokens based on whether they already appear in the generated text so far, encouraging the model to introduce new topics rather than repeat itself.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_PRESENCE_PENALTY

double

Random number generator seed to use in sampling mode for experimental repeatability.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_SEED

int

Defines one or more stop sequences that will cause the model to stop generating further tokens if any of them are encountered in the output.

This allows control over where the model should end its response. If a stop sequence is encountered before the minimum number of tokens has been generated, it will be ignored.

Possible values: 0 ≤ number of items ≤ 4

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_STOP

list of string

Specifies the sampling temperature to use in the generation process.

Higher values (e.g. 0.8) make the output more random and diverse, while lower values (e.g. 0.2) make the output more focused and deterministic.

Possible values: 0 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_TEMPERATURE

double

${quarkus.langchain4j.temperature:1.0}

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

The parameter is sent to the model only when it is set.

Possible values: 0 < value < 1

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_TOP_P

double

Specifies the desired format for the model’s output.

Allowable values: [text, json, json_schema]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_RESPONSE_FORMAT

text, json, json-schema

Whether the JSON Schema sent to the model should use the strict mode.

When enabled, the model is constrained to return a response that exactly matches the given JSON Schema. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set this property to false to let the model treat the schema as a hint instead of a constraint.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_STRICT_JSON_SCHEMA

boolean

true

Whether chat model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_LOG_REQUESTS

boolean

false

Whether chat model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_LOG_REQUESTS_CURL

boolean

false

Specifies a set of allowed output choices.

When this parameter is set, the model is constrained to return exactly one of the provided choices.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_GUIDED_CHOICE

list of string

Constrains the model output to follow a context-free grammar.

If specified, the generated output will conform to the defined grammar.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_GUIDED_GRAMMAR

string

Constrains the model output to match a regular expression pattern.

If specified, the generated output must conform to the provided regex.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_GUIDED_REGEX

string

Sets the length penalty to be applied during text generation. This penalty influences the length of the generated text. A length penalty discourages the model from generating overly long responses, or conversely, it can encourage more extended outputs.

When the penalty value is greater than 1.0, it discourages generating longer responses. Conversely, a value less than 1.0 incentivizes the model to generate longer text. A value of 1.0 means no penalty, and the length of the output will be determined by other factors, such as the input prompt and model’s natural completion behavior.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_LENGTH_PENALTY

double

Sets the repetition penalty to be applied during text generation. This penalty helps to discourage the model from repeating the same words or phrases too often.

The penalty value should be greater than 1.0 for repetition discouragement. A value of 1.0 means no penalty, and values above 1.0 increase the strength of the penalty.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_REPETITION_PENALTY

double

Enables or disables reasoning.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_ENABLED

boolean

The opening delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_TAGS_THINK_OPENING

string

required

The closing delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_TAGS_THINK_CLOSING

string

required

The opening delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_TAGS_RESPONSE_OPENING

string

required

The closing delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_TAGS_RESPONSE_CLOSING

string

required

Controls the reasoning effort level for models that separate reasoning and response automatically.

Example values: LOW, MEDIUM, HIGH.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_EFFORT

low, medium, high

Determines whether the reasoning portion returned by the model should be included in the final response provided to the application.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_THINKING_INCLUDE_REASONING

boolean

Specifies the model to use for the chat completion.

A list of all available models is provided in the IBM watsonx.ai documentation at the this link.

To use a model, locate the API model ID column in the table and copy the corresponding model ID.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_CHAT_MODEL_MODEL_NAME

string

ibm/granite-4-h-small

Specifies how the model should choose which tool to call during a request.

This value can be:

  • auto: The model decides whether and which tool to call automatically.

  • required: The model must call one of the available tools.

If toolChoiceName is set, this value is ignored.

Setting this value influences the tool-calling behavior of the model when no specific tool is required.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_TOOL_CHOICE

auto, required, none

Specifies the name of a specific tool that the model must call.

When set, the model will be forced to call the specified tool. The name must exactly match one of the available tools defined for the service.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_TOOL_CHOICE_NAME

string

Positive values penalize new tokens based on their existing frequency in the generated text, reducing the likelihood of the model repeating the same lines verbatim.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_FREQUENCY_PENALTY

double

Specifies whether to return the log probabilities of the output tokens.

If set to true, the response will include the log probability of each output token in the content of the message.

The parameter is sent to the model only when it is set.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_LOGPROBS

boolean

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. The option logprobs must be set to true if this parameter is used.

Possible values: 0 ≤ value ≤ 20

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_TOP_LOGPROBS

int

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length. Set to 0 for the model’s configured max generated tokens.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_MAX_OUTPUT_TOKENS

int

1024

Applies a penalty to new tokens based on whether they already appear in the generated text so far, encouraging the model to introduce new topics rather than repeat itself.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_PRESENCE_PENALTY

double

Random number generator seed to use in sampling mode for experimental repeatability.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_SEED

int

Defines one or more stop sequences that will cause the model to stop generating further tokens if any of them are encountered in the output.

This allows control over where the model should end its response. If a stop sequence is encountered before the minimum number of tokens has been generated, it will be ignored.

Possible values: 0 ≤ number of items ≤ 4

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_STOP

list of string

Specifies the sampling temperature to use in the generation process.

Higher values (e.g. 0.8) make the output more random and diverse, while lower values (e.g. 0.2) make the output more focused and deterministic.

Possible values: 0 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_TEMPERATURE

double

${quarkus.langchain4j.temperature:1.0}

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

The parameter is sent to the model only when it is set.

Possible values: 0 < value < 1

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_TOP_P

double

Specifies the desired format for the model’s output.

Allowable values: [text, json, json_schema]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_RESPONSE_FORMAT

text, json, json-schema

Whether the JSON Schema sent to the model should use the strict mode.

When enabled, the model is constrained to return a response that exactly matches the given JSON Schema. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set this property to false to let the model treat the schema as a hint instead of a constraint.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_STRICT_JSON_SCHEMA

boolean

true

Whether chat model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_LOG_REQUESTS

boolean

false

Whether chat model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_LOG_REQUESTS_CURL

boolean

false

Specifies a set of allowed output choices.

When this parameter is set, the model is constrained to return exactly one of the provided choices.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_GUIDED_CHOICE

list of string

Constrains the model output to follow a context-free grammar.

If specified, the generated output will conform to the defined grammar.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_GUIDED_GRAMMAR

string

Constrains the model output to match a regular expression pattern.

If specified, the generated output must conform to the provided regex.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_GUIDED_REGEX

string

Sets the length penalty to be applied during text generation. This penalty influences the length of the generated text. A length penalty discourages the model from generating overly long responses, or conversely, it can encourage more extended outputs.

When the penalty value is greater than 1.0, it discourages generating longer responses. Conversely, a value less than 1.0 incentivizes the model to generate longer text. A value of 1.0 means no penalty, and the length of the output will be determined by other factors, such as the input prompt and model’s natural completion behavior.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_LENGTH_PENALTY

double

Sets the repetition penalty to be applied during text generation. This penalty helps to discourage the model from repeating the same words or phrases too often.

The penalty value should be greater than 1.0 for repetition discouragement. A value of 1.0 means no penalty, and values above 1.0 increase the strength of the penalty.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_REPETITION_PENALTY

double

Enables or disables reasoning.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_ENABLED

boolean

The opening delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_THINK_OPENING

string

required

The closing delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_THINK_CLOSING

string

required

The opening delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_RESPONSE_OPENING

string

required

The closing delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_RESPONSE_CLOSING

string

required

Controls the reasoning effort level for models that separate reasoning and response automatically.

Example values: LOW, MEDIUM, HIGH.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_EFFORT

low, medium, high

Determines whether the reasoning portion returned by the model should be included in the final response provided to the application.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_THINKING_INCLUDE_REASONING

boolean

The deployment ID of the model deployed in watsonx.ai.

Setting this property routes all chat requests to the deployment chat API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_DEPLOYMENT_CHAT_MODEL_DEPLOYMENT_ID

string

Specifies how the model should choose which tool to call during a request.

This value can be:

  • auto: The model decides whether and which tool to call automatically.

  • required: The model must call one of the available tools.

If toolChoiceName is set, this value is ignored.

Setting this value influences the tool-calling behavior of the model when no specific tool is required.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_TOOL_CHOICE

auto, required, none

Specifies the name of a specific tool that the model must call.

When set, the model will be forced to call the specified tool. The name must exactly match one of the available tools defined for the service.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_TOOL_CHOICE_NAME

string

Positive values penalize new tokens based on their existing frequency in the generated text, reducing the likelihood of the model repeating the same lines verbatim.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_FREQUENCY_PENALTY

double

Specifies whether to return the log probabilities of the output tokens.

If set to true, the response will include the log probability of each output token in the content of the message.

The parameter is sent to the model only when it is set.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_LOGPROBS

boolean

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. The option logprobs must be set to true if this parameter is used.

Possible values: 0 ≤ value ≤ 20

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_TOP_LOGPROBS

int

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length. Set to 0 for the model’s configured max generated tokens.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_MAX_OUTPUT_TOKENS

int

1024

Applies a penalty to new tokens based on whether they already appear in the generated text so far, encouraging the model to introduce new topics rather than repeat itself.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_PRESENCE_PENALTY

double

Random number generator seed to use in sampling mode for experimental repeatability.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_SEED

int

Defines one or more stop sequences that will cause the model to stop generating further tokens if any of them are encountered in the output.

This allows control over where the model should end its response. If a stop sequence is encountered before the minimum number of tokens has been generated, it will be ignored.

Possible values: 0 ≤ number of items ≤ 4

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_STOP

list of string

Specifies the sampling temperature to use in the generation process.

Higher values (e.g. 0.8) make the output more random and diverse, while lower values (e.g. 0.2) make the output more focused and deterministic.

Possible values: 0 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_TEMPERATURE

double

${quarkus.langchain4j.temperature:1.0}

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

The parameter is sent to the model only when it is set.

Possible values: 0 < value < 1

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_TOP_P

double

Specifies the desired format for the model’s output.

Allowable values: [text, json, json_schema]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_RESPONSE_FORMAT

text, json, json-schema

Whether the JSON Schema sent to the model should use the strict mode.

When enabled, the model is constrained to return a response that exactly matches the given JSON Schema. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set this property to false to let the model treat the schema as a hint instead of a constraint.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_STRICT_JSON_SCHEMA

boolean

true

Whether chat model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_LOG_REQUESTS

boolean

false

Whether chat model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_LOG_REQUESTS_CURL

boolean

false

The identifier of the model to use, as configured in the Model Gateway (for example openai/gpt-4o-mini).

Setting this property routes all chat requests to the Model Gateway.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_MODEL_NAME

string

Specifies the latency tier used to serve the request.

Allowable values: [auto, default, flex, priority]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_SERVICE_TIER

auto, default, flex, priority

Constrains the effort spent on reasoning for reasoning models.

Reducing the reasoning effort can result in faster responses and fewer tokens used on reasoning.

Allowable values: [low, medium, high]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_REASONING_EFFORT

low, medium, high

Whether the semantic cache is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_CACHE_ENABLED

boolean

true

The similarity threshold a cached entry must reach to be served instead of calling the model.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_CACHE_THRESHOLD

double

provider specific

The output types that the model is requested to generate.

Most models are only able to generate text, which is the default.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_MODALITIES

list of string

Whether the generated output should be stored for model distillation or evaluations.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_STORE

boolean

Whether the model is allowed to run tool calls in parallel.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_PARALLEL_TOOL_CALLS

boolean

A stable identifier of the end user issuing the request, used by the backing provider to detect and prevent abuse.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_USER

string

A set of key/value pairs that is attached to the request and returned with the response.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_GATEWAY_CHAT_MODEL_METADATA__METADATA_KEY_

Map<String,String>

Specifies the ID of the model to be used.

A list of all available models is provided in the IBM watsonx.ai documentation at the this link.

To use a model, locate the API model ID column in the table and copy the corresponding model ID.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_EMBEDDING_MODEL_MODEL_NAME

string

ibm/granite-embedding-278m-multilingual

Whether embedding model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_EMBEDDING_MODEL_LOG_REQUESTS

boolean

false

Whether embedding model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_EMBEDDING_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_EMBEDDING_MODEL_LOG_REQUESTS_CURL

boolean

false

The id of the model to be used.

All available models are listed in the IBM Watsonx.ai documentation at the link: following link.

To use a model, locate the API model_id column in the table and copy the corresponding model ID.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCORING_MODEL_MODEL_NAME

string

cross-encoder/ms-marco-minilm-l-12-v2

Whether embedding model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCORING_MODEL_LOG_REQUESTS

boolean

false

Whether embedding model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCORING_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_SCORING_MODEL_LOG_REQUESTS_CURL

boolean

false

Indicates whether the PII moderation model is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_PII_ENABLED

boolean

required

Indicates whether the HAP moderation model is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_HAP_ENABLED

boolean

required

Threshold value for HAP moderation model.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_HAP_THRESHOLD

double

Indicates whether the GraniteGuardian moderation model is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_GRANITE_GUARDIAN_ENABLED

boolean

required

Threshold value for Granite Guardian moderation model.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_GRANITE_GUARDIAN_THRESHOLD

double

Whether moderation model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_LOG_REQUESTS

boolean

false

Whether moderation model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_MODERATION_MODEL_LOG_REQUESTS_CURL

boolean

false

Base URL for the built-in service.

All available URLs are listed in the IBM Watsonx.ai documentation at the following link.

Note: If empty, the URL is automatically calculated based on the watsonx.base-url value.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_BASE_URL

string

Timeout for built-in tools APIs.

If empty, the api key inherits the value from the watsonx.timeout property.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_TIMEOUT

Duration 

10s

Whether the built-in rest client should log requests.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_LOG_REQUESTS

boolean

false

Whether the built-in rest client should log responses.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_LOG_REQUESTS_CURL

boolean

false

Tavily API key.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_TAVILY_SEARCH_API_KEY

string

Deployment id.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_PYTHON_INTERPRETER_DEPLOYMENT_ID

string

Vector index ids

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX_BUILT_IN_TOOL_RAG_QUERY_VECTOR_INDEX_IDS

list of string

Named model config

Type

Default

Specifies the base URL of the watsonx.ai API.

A list of all available URLs is provided in the IBM Watsonx.ai documentation at the this link.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__BASE_URL

string

IBM Cloud API key.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__API_KEY

string

Timeout for watsonx.ai calls.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TIMEOUT

Duration 

60s

The version date for the API of the form YYYY-MM-DD.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__VERSION

string

The space that contains the resource.

Either space_id or project_id has to be given.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SPACE_ID

string

The project that contains the resource.

Either space_id or project_id has to be given.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__PROJECT_ID

string

Whether the watsonx.ai client should log requests.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__LOG_REQUESTS

boolean

false

Whether the watsonx.ai client should log responses.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__LOG_REQUESTS_CURL

boolean

false

Whether to enable the integration. Defaults to true, which means requests are made to the watsonx.ai provider. Set to false to disable all requests.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__ENABLE_INTEGRATION

boolean

true

Base URL of the IAM Authentication API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__IAM_BASE_URL

URI

Timeout for IAM authentication calls.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__IAM_TIMEOUT

Duration 

10s

Grant type for the IAM Authentication API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__IAM_GRANT_TYPE

string

Base URL of the Cloud Object Storage API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_COS_URL

string

required

The id of the connection asset that contains the credentials required to access the data.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_DOCUMENT_REFERENCE_CONNECTION

string

required

The name of the bucket containing the input document.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_DOCUMENT_REFERENCE_BUCKET_NAME

string

required

The id of the connection asset used to store the extracted results.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_RESULTS_REFERENCE_CONNECTION

string

required

The name of the bucket where the output files will be written.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_RESULTS_REFERENCE_BUCKET_NAME

string

required

Whether text extraction requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_LOG_REQUESTS

boolean

false

Whether text extraction responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_EXTRACTION_LOG_REQUESTS_CURL

boolean

false

Base URL of the Cloud Object Storage API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_CLASSIFICATION_COS_URL

string

required

The id of the connection asset that contains the credentials required to access the data.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_CLASSIFICATION_DOCUMENT_REFERENCE_CONNECTION

string

required

The name of the bucket containing the input document.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_CLASSIFICATION_DOCUMENT_REFERENCE_BUCKET_NAME

string

required

Whether text extraction requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_CLASSIFICATION_LOG_REQUESTS

boolean

false

Whether text extraction responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_CLASSIFICATION_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__TEXT_CLASSIFICATION_LOG_REQUESTS_CURL

boolean

false

Base URL of the Cloud Object Storage API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CREATE_COS_URL

string

required

The id of the connection asset that contains the credentials required to access the data.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CREATE_DOCUMENT_REFERENCE_CONNECTION

string

required

The name of the bucket containing the input document.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CREATE_DOCUMENT_REFERENCE_BUCKET_NAME

string

required

Whether create schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CREATE_LOG_REQUESTS

boolean

false

Whether create schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CREATE_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CREATE_LOG_REQUESTS_CURL

boolean

false

Whether improve schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_IMPROVE_LOG_REQUESTS

boolean

false

Whether improve schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_IMPROVE_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_IMPROVE_LOG_REQUESTS_CURL

boolean

false

Whether merge schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_MERGE_LOG_REQUESTS

boolean

false

Whether merge schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_MERGE_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_MERGE_LOG_REQUESTS_CURL

boolean

false

Whether cluster schema requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CLUSTER_LOG_REQUESTS

boolean

false

Whether cluster schema responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CLUSTER_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCHEMA_CLUSTER_LOG_REQUESTS_CURL

boolean

false

Specifies how the model should choose which tool to call during a request.

This value can be:

  • auto: The model decides whether and which tool to call automatically.

  • required: The model must call one of the available tools.

If toolChoiceName is set, this value is ignored.

Setting this value influences the tool-calling behavior of the model when no specific tool is required.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_TOOL_CHOICE

auto, required, none

Specifies the name of a specific tool that the model must call.

When set, the model will be forced to call the specified tool. The name must exactly match one of the available tools defined for the service.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_TOOL_CHOICE_NAME

string

Positive values penalize new tokens based on their existing frequency in the generated text, reducing the likelihood of the model repeating the same lines verbatim.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_FREQUENCY_PENALTY

double

Specifies whether to return the log probabilities of the output tokens.

If set to true, the response will include the log probability of each output token in the content of the message.

The parameter is sent to the model only when it is set.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_LOGPROBS

boolean

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. The option logprobs must be set to true if this parameter is used.

Possible values: 0 ≤ value ≤ 20

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_TOP_LOGPROBS

int

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length. Set to 0 for the model’s configured max generated tokens.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_MAX_OUTPUT_TOKENS

int

1024

Applies a penalty to new tokens based on whether they already appear in the generated text so far, encouraging the model to introduce new topics rather than repeat itself.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_PRESENCE_PENALTY

double

Random number generator seed to use in sampling mode for experimental repeatability.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_SEED

int

Defines one or more stop sequences that will cause the model to stop generating further tokens if any of them are encountered in the output.

This allows control over where the model should end its response. If a stop sequence is encountered before the minimum number of tokens has been generated, it will be ignored.

Possible values: 0 ≤ number of items ≤ 4

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_STOP

list of string

Specifies the sampling temperature to use in the generation process.

Higher values (e.g. 0.8) make the output more random and diverse, while lower values (e.g. 0.2) make the output more focused and deterministic.

Possible values: 0 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_TEMPERATURE

double

${quarkus.langchain4j.temperature:1.0}

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

The parameter is sent to the model only when it is set.

Possible values: 0 < value < 1

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_TOP_P

double

Specifies the desired format for the model’s output.

Allowable values: [text, json, json_schema]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_RESPONSE_FORMAT

text, json, json-schema

Whether the JSON Schema sent to the model should use the strict mode.

When enabled, the model is constrained to return a response that exactly matches the given JSON Schema. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set this property to false to let the model treat the schema as a hint instead of a constraint.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_STRICT_JSON_SCHEMA

boolean

true

Whether chat model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_LOG_REQUESTS

boolean

false

Whether chat model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_LOG_REQUESTS_CURL

boolean

false

Specifies a set of allowed output choices.

When this parameter is set, the model is constrained to return exactly one of the provided choices.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_GUIDED_CHOICE

list of string

Constrains the model output to follow a context-free grammar.

If specified, the generated output will conform to the defined grammar.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_GUIDED_GRAMMAR

string

Constrains the model output to match a regular expression pattern.

If specified, the generated output must conform to the provided regex.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_GUIDED_REGEX

string

Sets the length penalty to be applied during text generation. This penalty influences the length of the generated text. A length penalty discourages the model from generating overly long responses, or conversely, it can encourage more extended outputs.

When the penalty value is greater than 1.0, it discourages generating longer responses. Conversely, a value less than 1.0 incentivizes the model to generate longer text. A value of 1.0 means no penalty, and the length of the output will be determined by other factors, such as the input prompt and model’s natural completion behavior.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_LENGTH_PENALTY

double

Sets the repetition penalty to be applied during text generation. This penalty helps to discourage the model from repeating the same words or phrases too often.

The penalty value should be greater than 1.0 for repetition discouragement. A value of 1.0 means no penalty, and values above 1.0 increase the strength of the penalty.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_REPETITION_PENALTY

double

Enables or disables reasoning.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_ENABLED

boolean

The opening delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_TAGS_THINK_OPENING

string

required

The closing delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_TAGS_THINK_CLOSING

string

required

The opening delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_TAGS_RESPONSE_OPENING

string

required

The closing delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_TAGS_RESPONSE_CLOSING

string

required

Controls the reasoning effort level for models that separate reasoning and response automatically.

Example values: LOW, MEDIUM, HIGH.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_EFFORT

low, medium, high

Determines whether the reasoning portion returned by the model should be included in the final response provided to the application.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_THINKING_INCLUDE_REASONING

boolean

Specifies the model to use for the chat completion.

A list of all available models is provided in the IBM watsonx.ai documentation at the this link.

To use a model, locate the API model ID column in the table and copy the corresponding model ID.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__CHAT_MODEL_MODEL_NAME

string

ibm/granite-4-h-small

Specifies how the model should choose which tool to call during a request.

This value can be:

  • auto: The model decides whether and which tool to call automatically.

  • required: The model must call one of the available tools.

If toolChoiceName is set, this value is ignored.

Setting this value influences the tool-calling behavior of the model when no specific tool is required.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_TOOL_CHOICE

auto, required, none

Specifies the name of a specific tool that the model must call.

When set, the model will be forced to call the specified tool. The name must exactly match one of the available tools defined for the service.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_TOOL_CHOICE_NAME

string

Positive values penalize new tokens based on their existing frequency in the generated text, reducing the likelihood of the model repeating the same lines verbatim.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_FREQUENCY_PENALTY

double

Specifies whether to return the log probabilities of the output tokens.

If set to true, the response will include the log probability of each output token in the content of the message.

The parameter is sent to the model only when it is set.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_LOGPROBS

boolean

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. The option logprobs must be set to true if this parameter is used.

Possible values: 0 ≤ value ≤ 20

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_TOP_LOGPROBS

int

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length. Set to 0 for the model’s configured max generated tokens.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_MAX_OUTPUT_TOKENS

int

1024

Applies a penalty to new tokens based on whether they already appear in the generated text so far, encouraging the model to introduce new topics rather than repeat itself.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_PRESENCE_PENALTY

double

Random number generator seed to use in sampling mode for experimental repeatability.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_SEED

int

Defines one or more stop sequences that will cause the model to stop generating further tokens if any of them are encountered in the output.

This allows control over where the model should end its response. If a stop sequence is encountered before the minimum number of tokens has been generated, it will be ignored.

Possible values: 0 ≤ number of items ≤ 4

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_STOP

list of string

Specifies the sampling temperature to use in the generation process.

Higher values (e.g. 0.8) make the output more random and diverse, while lower values (e.g. 0.2) make the output more focused and deterministic.

Possible values: 0 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_TEMPERATURE

double

${quarkus.langchain4j.temperature:1.0}

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

The parameter is sent to the model only when it is set.

Possible values: 0 < value < 1

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_TOP_P

double

Specifies the desired format for the model’s output.

Allowable values: [text, json, json_schema]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_RESPONSE_FORMAT

text, json, json-schema

Whether the JSON Schema sent to the model should use the strict mode.

When enabled, the model is constrained to return a response that exactly matches the given JSON Schema. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set this property to false to let the model treat the schema as a hint instead of a constraint.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_STRICT_JSON_SCHEMA

boolean

true

Whether chat model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_LOG_REQUESTS

boolean

false

Whether chat model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_LOG_REQUESTS_CURL

boolean

false

Specifies a set of allowed output choices.

When this parameter is set, the model is constrained to return exactly one of the provided choices.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_GUIDED_CHOICE

list of string

Constrains the model output to follow a context-free grammar.

If specified, the generated output will conform to the defined grammar.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_GUIDED_GRAMMAR

string

Constrains the model output to match a regular expression pattern.

If specified, the generated output must conform to the provided regex.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_GUIDED_REGEX

string

Sets the length penalty to be applied during text generation. This penalty influences the length of the generated text. A length penalty discourages the model from generating overly long responses, or conversely, it can encourage more extended outputs.

When the penalty value is greater than 1.0, it discourages generating longer responses. Conversely, a value less than 1.0 incentivizes the model to generate longer text. A value of 1.0 means no penalty, and the length of the output will be determined by other factors, such as the input prompt and model’s natural completion behavior.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_LENGTH_PENALTY

double

Sets the repetition penalty to be applied during text generation. This penalty helps to discourage the model from repeating the same words or phrases too often.

The penalty value should be greater than 1.0 for repetition discouragement. A value of 1.0 means no penalty, and values above 1.0 increase the strength of the penalty.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_REPETITION_PENALTY

double

Enables or disables reasoning.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_ENABLED

boolean

The opening delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_THINK_OPENING

string

required

The closing delimiter for the model’s internal reasoning section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_THINK_CLOSING

string

required

The opening delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_RESPONSE_OPENING

string

required

The closing delimiter for the model’s final response section.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_TAGS_RESPONSE_CLOSING

string

required

Controls the reasoning effort level for models that separate reasoning and response automatically.

Example values: LOW, MEDIUM, HIGH.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_EFFORT

low, medium, high

Determines whether the reasoning portion returned by the model should be included in the final response provided to the application.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_THINKING_INCLUDE_REASONING

boolean

The deployment ID of the model deployed in watsonx.ai.

Setting this property routes all chat requests to the deployment chat API.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__DEPLOYMENT_CHAT_MODEL_DEPLOYMENT_ID

string

Specifies how the model should choose which tool to call during a request.

This value can be:

  • auto: The model decides whether and which tool to call automatically.

  • required: The model must call one of the available tools.

If toolChoiceName is set, this value is ignored.

Setting this value influences the tool-calling behavior of the model when no specific tool is required.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_TOOL_CHOICE

auto, required, none

Specifies the name of a specific tool that the model must call.

When set, the model will be forced to call the specified tool. The name must exactly match one of the available tools defined for the service.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_TOOL_CHOICE_NAME

string

Positive values penalize new tokens based on their existing frequency in the generated text, reducing the likelihood of the model repeating the same lines verbatim.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_FREQUENCY_PENALTY

double

Specifies whether to return the log probabilities of the output tokens.

If set to true, the response will include the log probability of each output token in the content of the message.

The parameter is sent to the model only when it is set.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_LOGPROBS

boolean

An integer specifying the number of most likely tokens to return at each token position, each with an associated log probability. The option logprobs must be set to true if this parameter is used.

Possible values: 0 ≤ value ≤ 20

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_TOP_LOGPROBS

int

The maximum number of tokens that can be generated in the chat completion. The total length of input tokens and generated tokens is limited by the model’s context length. Set to 0 for the model’s configured max generated tokens.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_MAX_OUTPUT_TOKENS

int

1024

Applies a penalty to new tokens based on whether they already appear in the generated text so far, encouraging the model to introduce new topics rather than repeat itself.

The parameter is sent to the model only when it is set.

Possible values: -2 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_PRESENCE_PENALTY

double

Random number generator seed to use in sampling mode for experimental repeatability.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_SEED

int

Defines one or more stop sequences that will cause the model to stop generating further tokens if any of them are encountered in the output.

This allows control over where the model should end its response. If a stop sequence is encountered before the minimum number of tokens has been generated, it will be ignored.

Possible values: 0 ≤ number of items ≤ 4

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_STOP

list of string

Specifies the sampling temperature to use in the generation process.

Higher values (e.g. 0.8) make the output more random and diverse, while lower values (e.g. 0.2) make the output more focused and deterministic.

Possible values: 0 < value < 2

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_TEMPERATURE

double

${quarkus.langchain4j.temperature:1.0}

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

The parameter is sent to the model only when it is set.

Possible values: 0 < value < 1

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_TOP_P

double

Specifies the desired format for the model’s output.

Allowable values: [text, json, json_schema]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_RESPONSE_FORMAT

text, json, json-schema

Whether the JSON Schema sent to the model should use the strict mode.

When enabled, the model is constrained to return a response that exactly matches the given JSON Schema. To satisfy the restrictions of the strict mode, all the properties of the schema are marked as required, the optional ones are made nullable and additionalProperties is set to false.

Set this property to false to let the model treat the schema as a hint instead of a constraint.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_STRICT_JSON_SCHEMA

boolean

true

Whether chat model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_LOG_REQUESTS

boolean

false

Whether chat model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_LOG_REQUESTS_CURL

boolean

false

The identifier of the model to use, as configured in the Model Gateway (for example openai/gpt-4o-mini).

Setting this property routes all chat requests to the Model Gateway.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_MODEL_NAME

string

Specifies the latency tier used to serve the request.

Allowable values: [auto, default, flex, priority]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_SERVICE_TIER

auto, default, flex, priority

Constrains the effort spent on reasoning for reasoning models.

Reducing the reasoning effort can result in faster responses and fewer tokens used on reasoning.

Allowable values: [low, medium, high]

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_REASONING_EFFORT

low, medium, high

Whether the semantic cache is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_CACHE_ENABLED

boolean

true

The similarity threshold a cached entry must reach to be served instead of calling the model.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_CACHE_THRESHOLD

double

provider specific

The output types that the model is requested to generate.

Most models are only able to generate text, which is the default.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_MODALITIES

list of string

Whether the generated output should be stored for model distillation or evaluations.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_STORE

boolean

Whether the model is allowed to run tool calls in parallel.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_PARALLEL_TOOL_CALLS

boolean

A stable identifier of the end user issuing the request, used by the backing provider to detect and prevent abuse.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_USER

string

A set of key/value pairs that is attached to the request and returned with the response.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__GATEWAY_CHAT_MODEL_METADATA__METADATA_KEY_

Map<String,String>

Specifies the ID of the model to be used.

A list of all available models is provided in the IBM watsonx.ai documentation at the this link.

To use a model, locate the API model ID column in the table and copy the corresponding model ID.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__EMBEDDING_MODEL_MODEL_NAME

string

ibm/granite-embedding-278m-multilingual

Whether embedding model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__EMBEDDING_MODEL_LOG_REQUESTS

boolean

false

Whether embedding model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__EMBEDDING_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__EMBEDDING_MODEL_LOG_REQUESTS_CURL

boolean

false

The id of the model to be used.

All available models are listed in the IBM Watsonx.ai documentation at the link: following link.

To use a model, locate the API model_id column in the table and copy the corresponding model ID.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCORING_MODEL_MODEL_NAME

string

cross-encoder/ms-marco-minilm-l-12-v2

Whether embedding model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCORING_MODEL_LOG_REQUESTS

boolean

false

Whether embedding model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCORING_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__SCORING_MODEL_LOG_REQUESTS_CURL

boolean

false

Indicates whether the PII moderation model is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_PII_ENABLED

boolean

required

Indicates whether the HAP moderation model is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_HAP_ENABLED

boolean

required

Threshold value for HAP moderation model.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_HAP_THRESHOLD

double

Indicates whether the GraniteGuardian moderation model is enabled.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_GRANITE_GUARDIAN_ENABLED

boolean

required

Threshold value for Granite Guardian moderation model.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_GRANITE_GUARDIAN_THRESHOLD

double

Whether moderation model requests should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_LOG_REQUESTS

boolean

false

Whether moderation model responses should be logged.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_LOG_RESPONSES

boolean

false

Whether the watsonx.ai client should log requests as cURL commands.

Environment variable: QUARKUS_LANGCHAIN4J_WATSONX__MODEL_NAME__MODERATION_MODEL_LOG_REQUESTS_CURL

boolean

false

About the Duration format

To write duration values, use the standard java.time.Duration format. See the Duration#parse() Java API documentation for more information.

You can also use a simplified format, starting with a number:

  • If the value is only a number, it represents time in seconds.

  • If the value is a number followed by ms, it represents time in milliseconds.

In other cases, the simplified format is translated to the java.time.Duration format for parsing:

  • If the value is a number followed by h, m, or s, it is prefixed with PT.

  • If the value is a number followed by d, it is prefixed with P.