org.llm4s.llmconnect.model

Members list

Type members

Classlikes

case class AssistantMessage(contentOpt: Option[String], toolCalls: Seq[ToolCall]) extends Message

Represents a message from the LLM assistant, which may include text, tool calls or both.

Represents a message from the LLM assistant, which may include text, tool calls or both.

Value parameters

contentOpt

Optional content of the message.

toolCalls

Sequence of tool calls made by the assistant.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Message
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case object Audio extends Modality

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Modality
class Object
trait Matchable
class Any
Show all
Self type
Audio.type
final case class AudioInput(samples: Array[Float], sampleRate: Int) extends MMInput

Audio as mono float32 PCM with sample rate.

Audio as mono float32 PCM with sample rate.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MMInput
class Object
trait Matchable
class Any
Show all
final case class ChunkDelta(content: Option[String], role: Option[String], toolCalls: List[ToolCall])

Delta information for streaming chunks

Delta information for streaming chunks

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ChunkDelta

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ChunkDelta.type
case class Completion(id: String, created: Long, content: String, model: String, message: AssistantMessage, toolCalls: List[ToolCall], usage: Option[TokenUsage], thinking: Option[String])

Represents a completion response from an LLM. This includes the ID, creation timestamp, the assistant's message, and optional token usage statistics.

Represents a completion response from an LLM. This includes the ID, creation timestamp, the assistant's message, and optional token usage statistics.

Value parameters

content

The main content of the response.

created

Timestamp of when the completion was created.

id

Unique identifier for the completion.

message

The assistant's message in response to the user's input.

model

The model that generated this completion.

thinking

Optional thinking/reasoning content from extended thinking models. Present when using reasoning modes with Claude or o1/o3 models.

toolCalls

List of tool calls made by the assistant.

usage

Optional token usage statistics for the completion.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class CompletionChunk(id: String, content: Option[String], toolCall: Option[ToolCall], finishReason: Option[String], delta: ChunkDelta)

Represents a streaming chunk of completion data

Represents a streaming chunk of completion data

Attributes

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

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)
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Conversation(messages: Seq[Message])

Represents the message stream in a conversation. Typically this will be a sequence of system prompt, then a series of user message and assistant responses. After the system message we have a user message. The next message is the assistant response. If the conversation is ongoing, the next message will be a user message, or if the previous AssistantMessage requested one or more tool calls it will be followed by ToolMessages in response to each requested tool.

Represents the message stream in a conversation. Typically this will be a sequence of system prompt, then a series of user message and assistant responses. After the system message we have a user message. The next message is the assistant response. If the conversation is ongoing, the next message will be a user message, or if the previous AssistantMessage requested one or more tool calls it will be followed by ToolMessages in response to each requested tool.

Value parameters

messages

Sequence of messages in the conversation.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Conversation

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
final case class EmbeddingError(code: Option[String], message: String, provider: String) extends LLMError

EmbeddingError represents a structured error returned from an embedding provider (e.g., OpenAI or VoyageAI) or local encoders/extractors.

EmbeddingError represents a structured error returned from an embedding provider (e.g., OpenAI or VoyageAI) or local encoders/extractors.

Value parameters

code

Optional error code, typically an HTTP status (e.g., "401", "400").

message

Human-readable error message from the provider or client.

provider

Source component ("openai", "voyage", "encoder", "extractor", etc.)

Attributes

Supertypes
trait LLMError
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class EmbeddingRequest(input: Seq[String], model: EmbeddingModelConfig)

Text-only embedding request used by HTTP providers (OpenAI/Voyage).

Text-only embedding request used by HTTP providers (OpenAI/Voyage).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class EmbeddingResponse(embeddings: Seq[Seq[Double]], metadata: Map[String, String], modality: Option[Modality], dim: Option[Int], usage: Option[EmbeddingUsage])

Successful response carrying embedding vectors and lightweight metadata.

Successful response carrying embedding vectors and lightweight metadata.

Value parameters

dim

Optional dimensionality, if convenient to surface at response-level.

embeddings

One vector per input text/chunk (or per item).

metadata

Provider/model info etc. (e.g., "provider" -> "openai", "model" -> "...").

modality

Optional overall modality tag (Text, Audio, Video) when known.

usage

Optional token usage statistics (available from providers like OpenAI). Notes:

  • Defaults on metadata, modality, dim, and usage keep old call-sites source-compatible.
  • Providers can set modality/dim/usage when they know it; callers can ignore safely.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case class EmbeddingUsage(promptTokens: Int, totalTokens: Int)

Token usage statistics for an embedding request.

Token usage statistics for an embedding request.

Value parameters

promptTokens

Number of tokens in the input text(s).

totalTokens

Total tokens used (same as promptTokens for embeddings).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class EmbeddingVector(id: String, modality: Modality, model: String, dim: Int, values: Array[Float], meta: Map[String, String])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class ExtractorError(message: String, `type`: String, path: Option[String])

ExtractorError represents failures during file/media extraction.

ExtractorError represents failures during file/media extraction.

Value parameters

message

Human-readable explanation of the failure.

path

Optional path to the problematic file for debugging.

type

Coarse category (e.g., "FileNotFound", "UnsupportedType", "PDF", "DOCX", "PlainText", "ImageReadError", "AudioUnsupported", "AudioError", "VideoUnsupported").

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case object Image extends Modality

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Modality
class Object
trait Matchable
class Any
Show all
Self type
Image.type
final case class ImageInput(width: Int, height: Int, channels: Int, data: Array[Byte]) extends MMInput

Image as raw bytes (e.g., RGB or BGR interleaved) with basic shape metadata.

Image as raw bytes (e.g., RGB or BGR interleaved) with basic shape metadata.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MMInput
class Object
trait Matchable
class Any
Show all
sealed trait MMInput

Typed payloads for multimedia inputs. Keep lightweight, encode-friendly.

Typed payloads for multimedia inputs. Keep lightweight, encode-friendly.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
sealed trait Message

Represents a message in a conversation with an LLM (Large Language Model).

Represents a message in a conversation with an LLM (Large Language Model).

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Message

Message validation with comprehensive conversation flow rules

Message validation with comprehensive conversation flow rules

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Message.type
sealed trait MessageRole

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Assistant
object System
object Tool
object User
object MessageRole

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait Modality

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Audio
object Image
object Text
object Video
final case class MultimediaEmbeddingRequest(inputs: Seq[MMInput], model: EmbeddingModelConfig, modality: Modality, meta: Map[String, String])

Multimedia request (co-located in the same file to avoid new source files). Used by local encoders/facades (e.g., UniversalEncoder). Not sent to HTTP providers.

Multimedia request (co-located in the same file to avoid new source files). Used by local encoders/facades (e.g., UniversalEncoder). Not sent to HTTP providers.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
sealed trait ReasoningEffort

Represents the level of reasoning effort to request from the LLM.

Represents the level of reasoning effort to request from the LLM.

Different providers implement reasoning in different ways:

  • OpenAI o1/o3 models: Uses reasoning_effort parameter
  • Anthropic Claude: Uses extended thinking with budget_tokens

For non-reasoning models, this setting is silently ignored.

Attributes

Example
import org.llm4s.llmconnect.model._
// Use high reasoning for complex tasks
val options = CompletionOptions().withReasoning(ReasoningEffort.High)
// Parse from string
val effort = ReasoningEffort.fromString("medium")
Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object High
object Low
object Medium
object None

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
case class StreamedChunk(id: String, content: Option[String], toolCall: Option[ToolCall], finishReason: Option[String], thinkingDelta: Option[String])

Represents a streamed chunk of completion data.

Represents a streamed chunk of completion data.

Value parameters

content

Optional text content delta.

finishReason

Optional reason for stream completion.

id

Unique identifier for the stream.

thinkingDelta

Optional thinking/reasoning content delta. Present when streaming extended thinking content.

toolCall

Optional tool call information.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final case class SystemMessage(content: String) extends Message

Represents a system message, which is typically used to set context or instructions for the LLM.

Represents a system message, which is typically used to set context or instructions for the LLM.

A system prompt provides the foundational instructions and behavioral guidelines that shape how the LLM should respond to a user request, including its personality, capabilities, constraints, and communication style. It acts as the model's "operating manual," establishing context about what it should and shouldn't do, how to handle various scenarios, and what information it has access to.

Value parameters

content

Content of the system message.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Message
class Object
trait Matchable
class Any
Show all
object SystemMessage

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case object Text extends Modality

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Modality
class Object
trait Matchable
class Any
Show all
Self type
Text.type
final case class TextChunkInput(chunks: Seq[String]) extends MMInput

Text as pre-chunked strings (optional helper for local text paths).

Text as pre-chunked strings (optional helper for local text paths).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MMInput
class Object
trait Matchable
class Any
Show all
case class TokenUsage(promptTokens: Int, completionTokens: Int, totalTokens: Int, thinkingTokens: Option[Int])

Token usage statistics for a completion request.

Token usage statistics for a completion request.

Value parameters

completionTokens

Number of tokens in the completion (output).

promptTokens

Number of tokens in the prompt (input).

thinkingTokens

Optional number of tokens used for thinking/reasoning. Present when using reasoning modes with Claude or o1/o3 models. These tokens count toward billing but are separate from completion tokens.

totalTokens

Total tokens (prompt + completion).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class ToolCall(id: String, name: String, arguments: Value)

Represents a tool call request from the LLM.

Represents a tool call request from the LLM.

Value parameters

arguments

Arguments passed to the tool in JSON format.

id

Unique identifier for the tool call (generated byt the LLM).

name

Name of the tool being called. (from the list of tools provided to the LLM).

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object ToolCall

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
ToolCall.type
final case class ToolMessage(content: String, toolCallId: String) extends Message

Represents a message from a tool, typically containing the result of a tool call.

Represents a message from a tool, typically containing the result of a tool call.

Value parameters

content

Content of the tool message, usually the result of the tool execution, e.g. a json response.

toolCallId

Unique identifier for the tool call (as provided by the ToolCall).

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Message
class Object
trait Matchable
class Any
Show all
object ToolMessage

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object TraceHelper

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final case class UserMessage(content: String) extends Message

Represents a user message in the conversation.

Represents a user message in the conversation.

Value parameters

content

Content of the user message.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Message
class Object
trait Matchable
class Any
Show all
object UserMessage

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case object Video extends Modality

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait Modality
class Object
trait Matchable
class Any
Show all
Self type
Video.type
final case class VideoInput(frameWidth: Int, frameHeight: Int, channels: Int, fps: Int, frames: Seq[Array[Byte]]) extends MMInput

Video as a sequence of RGB frames (byte arrays), plus basic shape & fps.

Video as a sequence of RGB frames (byte arrays), plus basic shape & fps.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait MMInput
class Object
trait Matchable
class Any
Show all