Represents options for a completion request.
Value parameters
- budgetTokens
-
Optional explicit budget for thinking tokens (Anthropic Claude). If set, overrides the default budget from reasoning effort level.
- frequencyPenalty
-
Penalizes new tokens based on their existing frequency in the text so far, discouraging repetition.
- maxTokens
-
Optional maximum number of tokens to generate in the completion.
- presencePenalty
-
Penalizes new tokens based on whether they appear in the text so far, encouraging new topics.
- reasoning
-
Optional reasoning effort level for models that support extended thinking (o1/o3, Claude). For non-reasoning models, this setting is silently ignored.
- responseFormat
-
Optional structured output format (e.g. JSON or JSON schema). Support is provider- and model-dependent; see capability validation in RequestTransformer.
- temperature
-
Controls the randomness of the output. Higher values make the output more random. Note: Reasoning models (o1/o3) ignore this setting.
- tools
-
Optional sequence of tool function definitions that can be requested by the LLM during a completion.
- topP
-
Controls the diversity of the output. Lower values make the output more focused.
Attributes
- Example
-
import org.llm4s.llmconnect.model._ // Enable high reasoning for complex tasks val options = CompletionOptions() .withReasoning(ReasoningEffort.High) .copy(maxTokens = Some(4096)) // For Anthropic, set explicit thinking budget val anthropicOptions = CompletionOptions() .withBudgetTokens(16000) // Request JSON output (provider-dependent) val jsonOptions = CompletionOptions().withResponseFormat(ResponseFormat.Json) - Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Get the effective budget tokens for Anthropic extended thinking.
Get the effective budget tokens for Anthropic extended thinking.
Returns explicit budgetTokens if set, otherwise derives from reasoning effort.
Attributes
Check if reasoning is enabled.
Check if reasoning is enabled.
Attributes
Sets or clears the explicit budget for thinking tokens (Anthropic Claude). If set, it overrides the default budget from the reasoning effort level.
Sets or clears the explicit budget for thinking tokens (Anthropic Claude). If set, it overrides the default budget from the reasoning effort level.
Value parameters
- budgetTokens
-
the thinking token budget;
Nonesets no explicit budget (the default), so the budget comes from the reasoning effort level, if any
Attributes
- Returns
-
new CompletionOptions with budgetTokens set
Enable reasoning with explicit token budget for thinking (Anthropic Claude).
Enable reasoning with explicit token budget for thinking (Anthropic Claude).
This overrides the default budget from the reasoning effort level.
Value parameters
- tokens
-
the number of tokens to budget for thinking
Attributes
- Returns
-
new CompletionOptions with budget tokens set
Sets the frequency penalty, which penalizes new tokens based on their existing frequency in the text so far, discouraging repetition.
Sets the frequency penalty, which penalizes new tokens based on their existing frequency in the text so far, discouraging repetition.
Value parameters
- frequencyPenalty
-
the frequency penalty (default 0.0)
Attributes
- Returns
-
new CompletionOptions with frequencyPenalty set
Limits the number of tokens generated in the completion.
Limits the number of tokens generated in the completion.
Value parameters
- maxTokens
-
the maximum number of tokens to generate
Attributes
- Returns
-
new CompletionOptions with maxTokens set to
Some(maxTokens)
Sets or clears the limit on the number of tokens generated in the completion.
Sets or clears the limit on the number of tokens generated in the completion.
Value parameters
- maxTokens
-
the maximum number of tokens to generate;
Nonesets no limit (the default)
Attributes
- Returns
-
new CompletionOptions with maxTokens set
Sets the presence penalty, which penalizes new tokens based on whether they appear in the text so far, encouraging new topics.
Sets the presence penalty, which penalizes new tokens based on whether they appear in the text so far, encouraging new topics.
Value parameters
- presencePenalty
-
the presence penalty (default 0.0)
Attributes
- Returns
-
new CompletionOptions with presencePenalty set
Sets or clears the reasoning effort level for models that support extended thinking (o1/o3, Claude). For non-reasoning models, this setting is silently ignored.
Sets or clears the reasoning effort level for models that support extended thinking (o1/o3, Claude). For non-reasoning models, this setting is silently ignored.
Value parameters
- reasoning
-
the reasoning effort level;
Nonesets no reasoning effort (the default)
Attributes
- Returns
-
new CompletionOptions with reasoning set
Enable reasoning with the specified effort level.
Enable reasoning with the specified effort level.
Value parameters
- effort
-
the reasoning effort level
Attributes
- Returns
-
new CompletionOptions with reasoning enabled
Sets or clears the structured output format (e.g. JSON or JSON schema). Support is provider- and model-dependent; see capability validation in RequestTransformer.
Sets or clears the structured output format (e.g. JSON or JSON schema). Support is provider- and model-dependent; see capability validation in RequestTransformer.
Value parameters
- responseFormat
-
the desired response format;
Nonerequests no particular format (the default)
Attributes
- Returns
-
new CompletionOptions with responseFormat set
Request structured output in the given format.
Request structured output in the given format.
Support is provider- and model-dependent. Capability validation is applied via RequestTransformer (Json: fallback when unsupported; JsonSchema: strict error).
Value parameters
- format
-
the desired response format (e.g. ResponseFormat.Json or ResponseFormat.JsonSchema(schema))
Attributes
- Returns
-
new CompletionOptions with responseFormat set
Sets the sampling temperature. Higher values make the output more random. Reasoning models (o1/o3) ignore this setting.
Sets the sampling temperature. Higher values make the output more random. Reasoning models (o1/o3) ignore this setting.
Value parameters
- temperature
-
the sampling temperature (default 0.7)
Attributes
- Returns
-
new CompletionOptions with temperature set
Sets the tool function definitions that the LLM can request during a completion. Replaces any tools set before.
Sets the tool function definitions that the LLM can request during a completion. Replaces any tools set before.
Value parameters
- tools
-
the tools to offer; an empty sequence offers none (the default)
Attributes
- Returns
-
new CompletionOptions with tools set
Sets the nucleus sampling value. Lower values make the output more focused.
Sets the nucleus sampling value. Lower values make the output more focused.
Value parameters
- topP
-
the top-p value (default 1.0)
Attributes
- Returns
-
new CompletionOptions with topP set
Inherited methods
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product