CompletionOptions

org.llm4s.llmconnect.model.CompletionOptions
case class CompletionOptions(temperature: Double, topP: Double, maxTokens: Option[Int], presencePenalty: Double, frequencyPenalty: Double, tools: Seq[ToolFunction[_, _]], reasoning: Option[ReasoningEffort], budgetTokens: Option[Int])

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.

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)
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def effectiveBudgetTokens: Option[Int]

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

def hasReasoning: Boolean

Check if reasoning is enabled.

Check if reasoning is enabled.

Attributes

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

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

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product