# `LangChain.Message.Citation`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.0/lib/message/citation.ex#L1)

Represents a citation linking a span of response text to a source.

All four major providers (Anthropic, OpenAI, Google, Perplexity) share the
pattern of linking response text to sources. This struct normalizes those
provider-specific formats into a common shape.

## Fields

- `:cited_text` - The actual text cited from the source (when available)
- `:source` - A `CitationSource` identifying where the citation came from
- `:start_index` - Character offset into the ContentPart's text where this
  citation starts
- `:end_index` - Character offset where this citation ends
- `:confidence` - Confidence score (0.0-1.0) when provided (e.g., Gemini)
- `:metadata` - Provider-specific data for round-tripping. String keys for
  JSON serialization.

# `t`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.0/lib/message/citation.ex#L38)

```elixir
@type t() :: %LangChain.Message.Citation{
  cited_text: term(),
  confidence: term(),
  end_index: term(),
  metadata: term(),
  source: term(),
  start_index: term()
}
```

# `filter_by_source_type`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.0/lib/message/citation.ex#L79)

```elixir
@spec filter_by_source_type([t()], atom()) :: [t()]
```

Filters citations by source type.

# `new`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.0/lib/message/citation.ex#L50)

```elixir
@spec new(map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
```

# `new!`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.0/lib/message/citation.ex#L57)

```elixir
@spec new!(map()) :: t() | no_return()
```

# `source_urls`
[🔗](https://github.com/brainlid/langchain/blob/v0.8.0/lib/message/citation.ex#L68)

```elixir
@spec source_urls([t()]) :: [String.t()]
```

Returns all unique source URLs from a list of citations.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
