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

Members list

Value members

Concrete methods

def hasSpan: Boolean

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

def withCitedText(citedText: String): Citation
def withCitedText(citedText: Option[String]): Citation
def withEndIndex(endIndex: Int): Citation
def withEndIndex(endIndex: Option[Int]): Citation
def withStartIndex(startIndex: Int): Citation
def withStartIndex(startIndex: Option[Int]): Citation
def withTitle(title: String): Citation
def withTitle(title: Option[String]): Citation
def withUrl(url: String): Citation

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product