Completion

org.llm4s.llmconnect.model.Completion
See theCompletion companion object
@Stable
final case class Completion

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

Value parameters

citations

The sources the model cited in its answer, when the provider reports them (see Citation); empty for a model that does not search or does not cite, and for a completion assembled from streamed chunks, which carry none.

content

The main content of the response.

created

When the completion was created. Providers that report a creation time (the OpenAI-format created field, epoch seconds) are converted at the wire boundary; providers that report none stamp the time the response was received.

estimatedCost

Optional estimated cost of this completion in USD. Computed from token usage and model pricing when available.

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.

toolCalls

List of tool calls made by the assistant.

usage

Optional token usage statistics for the completion.

Attributes

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

Members list

Value members

Concrete methods

def asText: String

Extract content as text (for compatibility)

Extract content as text (for compatibility)

Attributes

def fullContent: String

Get the full response including thinking content (if available).

Get the full response including thinking content (if available).

Returns thinking wrapped in XML-style tags followed by the main content. Useful for logging or debugging the model's reasoning process.

Attributes

def hasCitations: Boolean

Check if the provider reported any Citation for this completion

Check if the provider reported any Citation for this completion

Attributes

def hasThinking: Boolean

Whether the completion carries thinking, text or redacted (see AssistantMessage.hasThinking). A completion whose only reasoning is redacted has thinking but no thinking text.

Whether the completion carries thinking, text or redacted (see AssistantMessage.hasThinking). A completion whose only reasoning is redacted has thinking but no thinking text.

Attributes

def hasToolCalls: Boolean

Check if completion contains tool calls

Check if completion contains tool calls

Attributes

def thinking: Option[String]

The text of the model's thinking/reasoning, when the provider reports it: the thinking text of message (see AssistantMessage.thinking), which is where clients put it so that it stays in the conversation history. Set it with withMessage(message.withThinking(...)).

The text of the model's thinking/reasoning, when the provider reports it: the thinking text of message (see AssistantMessage.thinking), which is where clients put it so that it stays in the conversation history. Set it with withMessage(message.withThinking(...)).

Attributes

def withCitations(citations: List[Citation]): Completion
def withContent(content: String): Completion
def withCreated(created: Instant): Completion
def withEstimatedCost(estimatedCost: Double): Completion
def withEstimatedCost(estimatedCost: Option[Double]): Completion
def withId(id: String): Completion
def withModel(model: String): Completion
def withToolCalls(toolCalls: List[ToolCall]): Completion
def withUsage(usage: Option[TokenUsage]): Completion

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product