public static final class ChatRequest.Builder
- Object
- ChatRequest.Builder
Mutable fluent builder for
ChatRequest. Collection arguments
are copied when the immutable request is built.Methods
Inherited methods
Method details
model
public ChatRequest.Builder model(String model)Selects a provider model.
Parameters
modelString- provider model id;
nulluses the client default
Returns
this builder
messages
public ChatRequest.Builder messages(List<ChatMessage> messages)Replaces the conversation history.
Parameters
messagesList<ChatMessage>- messages in chronological order;
nullclears them
Returns
this builder
addMessage
public ChatRequest.Builder addMessage(ChatMessage m)Appends one conversation message.
Parameters
mChatMessage- message to append
Returns
this builder
temperature
public ChatRequest.Builder temperature(Float t)Sets sampling temperature.
Parameters
tFloat- provider-supported temperature, or
nullto omit
Returns
this builder
maxTokens
public ChatRequest.Builder maxTokens(Integer n)Limits response length.
Parameters
nInteger- maximum generated token count, or
nullto omit
Returns
this builder
topP
public ChatRequest.Builder topP(Float p)Sets nucleus sampling probability.
Parameters
pFloat- provider-supported probability, or
nullto omit
Returns
this builder
stopSequences
public ChatRequest.Builder stopSequences(List<String> stops)Sets sequences that terminate generation.
Parameters
stopsList<String>- stop strings, or
nullfor none
Returns
this builder
seed
public ChatRequest.Builder seed(Long seed)Requests deterministic sampling where supported.
Parameters
seedLong- provider sampling seed, or
nullto omit
Returns
this builder
responseFormat
public ChatRequest.Builder responseFormat(ResponseFormat f)Requests text or structured JSON output.
Parameters
fResponseFormat- desired format, or
nullfor provider default
Returns
this builder
tools
public ChatRequest.Builder tools(List<Tool> tools)Replaces the callable tools advertised to the model.
Parameters
toolsList<Tool>- tool definitions, or
nullfor none
Returns
this builder
toolChoice
public ChatRequest.Builder toolChoice(ToolChoice choice)Controls whether and which tool the model may call.
Parameters
choiceToolChoice- selection policy, or
nullfor provider default
Returns
this builder
metadata
public ChatRequest.Builder metadata(Map<String, String> meta)Attaches provider-specific request metadata.
Parameters
metaMap<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
fSafetyFilter- safety policy, or
nullto 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