public static final class ChatRequest.Builder

  1. Object
  2. ChatRequest.Builder
Mutable fluent builder for ChatRequest. Collection arguments are copied when the immutable request is built.

Methods

public ChatRequest.Builder model(String model)Selects a provider model.
public ChatRequest.Builder messages(List<ChatMessage> messages)Replaces the conversation history.
public ChatRequest.Builder addMessage(ChatMessage m)Appends one conversation message.
public ChatRequest.Builder temperature(Float t)Sets sampling temperature.
public ChatRequest.Builder maxTokens(Integer n)Limits response length.
public ChatRequest.Builder topP(Float p)Sets nucleus sampling probability.
public ChatRequest.Builder stopSequences(List<String> stops)Sets sequences that terminate generation.
public ChatRequest.Builder seed(Long seed)Requests deterministic sampling where supported.
public ChatRequest.Builder responseFormat(ResponseFormat f)Requests text or structured JSON output.
public ChatRequest.Builder tools(List<Tool> tools)Replaces the callable tools advertised to the model.
public ChatRequest.Builder toolChoice(ToolChoice choice)Controls whether and which tool the model may call.
public ChatRequest.Builder metadata(Map<String, String> meta)Attaches provider-specific request metadata.
public ChatRequest.Builder safetyFilter(SafetyFilter f)Installs a client-side filter evaluated before network submission.
public ChatRequest build()Validates and creates an immutable request.

Inherited methods

Method details

model

public ChatRequest.Builder model(String model)
Selects a provider model.

Parameters

model String
provider model id; null uses the client default

Returns

this builder

messages

public ChatRequest.Builder messages(List<ChatMessage> messages)
Replaces the conversation history.

Parameters

messages List<ChatMessage>
messages in chronological order; null clears them

Returns

this builder

addMessage

public ChatRequest.Builder addMessage(ChatMessage m)
Appends one conversation message.

Parameters

m ChatMessage
message to append

Returns

this builder

temperature

public ChatRequest.Builder temperature(Float t)
Sets sampling temperature.

Parameters

t Float
provider-supported temperature, or null to omit

Returns

this builder

maxTokens

public ChatRequest.Builder maxTokens(Integer n)
Limits response length.

Parameters

n Integer
maximum generated token count, or null to omit

Returns

this builder

topP

public ChatRequest.Builder topP(Float p)
Sets nucleus sampling probability.

Parameters

p Float
provider-supported probability, or null to omit

Returns

this builder

stopSequences

public ChatRequest.Builder stopSequences(List<String> stops)
Sets sequences that terminate generation.

Parameters

stops List<String>
stop strings, or null for none

Returns

this builder

seed

public ChatRequest.Builder seed(Long seed)
Requests deterministic sampling where supported.

Parameters

seed Long
provider sampling seed, or null to omit

Returns

this builder

responseFormat

public ChatRequest.Builder responseFormat(ResponseFormat f)
Requests text or structured JSON output.

Parameters

f ResponseFormat
desired format, or null for provider default

Returns

this builder

tools

public ChatRequest.Builder tools(List<Tool> tools)
Replaces the callable tools advertised to the model.

Parameters

tools List<Tool>
tool definitions, or null for none

Returns

this builder

toolChoice

public ChatRequest.Builder toolChoice(ToolChoice choice)
Controls whether and which tool the model may call.

Parameters

choice ToolChoice
selection policy, or null for provider default

Returns

this builder

metadata

public ChatRequest.Builder metadata(Map<String, String> meta)
Attaches provider-specific request metadata.

Parameters

meta Map<String, String>
metadata copied into the request, or null

Returns

this builder

safetyFilter

public ChatRequest.Builder safetyFilter(SafetyFilter f)
Installs a client-side filter evaluated before network submission.

Parameters

f SafetyFilter
safety policy, or null to disable it

Returns

this builder

build

public ChatRequest build()
Validates and creates an immutable request.

Returns

completed request

Throws

IllegalStateException
when no messages were supplied