Citation

org.llm4s.llmconnect.model.Citation
See theCitation companion object
@Stable
final case class Citation

A source a model cited in its answer, as a provider reports it: where the claim came from and, when the provider says, where in the answer the inline citation sits. Provider-neutral: a provider that does not report a field leaves it None, and nothing here is invented.

Models that search the web by themselves report citations (OpenAI's Chat Completions search models - gpt-5-search-api, since the *-search-preview models were retired on 2026-07-23 - and OpenRouter's :online models, both as url_citation annotations). They arrive on Completion.citations; a completion from any other model has none.

Value parameters

citedText

A passage of the source, when the provider returns one with the citation (OpenRouter's content). It describes the source, not the answer.

endIndex

Where the inline citation ends; see startIndex.

startIndex

Where the inline citation starts, as the provider reports it: a position in Completion.content. OpenAI documents the two indices as the first and last character "of the URL citation in the message": they locate the citation itself, and no provider documents them as the span of prose the source supports, so do not highlight the text between them as the supported claim. Whether endIndex is inclusive is also the provider's call: check its convention before cutting content with it.

title

The source's title, when the provider reports one.

url

The cited source's URL, exactly as the provider returned it.

Attributes

Companion
object
Source
Citation.scala
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Whether the provider said where in the answer this citation sits (both indices present).

Whether the provider said where in the answer this citation sits (both indices present).

Attributes

Source
Citation.scala
def withCitedText(citedText: String): Citation

Attributes

Source
Citation.scala
def withCitedText(citedText: Option[String]): Citation

Attributes

Source
Citation.scala
def withEndIndex(endIndex: Int): Citation

Attributes

Source
Citation.scala
def withEndIndex(endIndex: Option[Int]): Citation

Attributes

Source
Citation.scala
def withStartIndex(startIndex: Int): Citation

Attributes

Source
Citation.scala
def withStartIndex(startIndex: Option[Int]): Citation

Attributes

Source
Citation.scala
def withTitle(title: String): Citation

Attributes

Source
Citation.scala

Attributes

Source
Citation.scala
def withUrl(url: String): Citation

Attributes

Source
Citation.scala

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product