Feature Request
Rig's Anthropic provider supports document content blocks, but it does not currently expose Claude's Messages API citations surface.
Anthropic supports enabling citations on document blocks with:
"citations": { "enabled": true }
When enabled, Claude returns citation metadata on response text blocks, including location types such as char_location, page_location, and content_block_location. Streaming responses can also include citations_delta.
Current Rig behavior in rig-core v0.37.0:
crates/rig-core/src/providers/anthropic/completion.rs models Content::Document with only source and cache_control.
message::Document has additional_params, but the Anthropic conversion currently ignores those provider-specific fields when building Content::Document.
- Anthropic response conversion maps text blocks into generic
AssistantContent::Text, which has no place to preserve citation metadata.
Related prior work: #1358 added plain text document support for Anthropic, but explicitly did not enable citations.
Motivation
Provider-native citations are useful for document QA, RAG, grading/review workflows, and any application that needs grounded model output with machine-readable links back to source documents.
Without this support, downstream users must bypass Rig and call Anthropic or Anthropic-compatible proxies directly to enable citations and parse the citation-bearing response shape. That loses Rig's normal provider abstraction, response conversion, telemetry, and usage handling.
Proposal
Add Anthropic citation support for document content blocks and responses.
Suggested scope:
- Add an Anthropic citation config type, e.g.
citations: { enabled: true }, on supported Anthropic document content blocks.
- Ensure generic
Document::additional_params is either intentionally forwarded for Anthropic document fields or provide a typed Anthropic-specific builder/API for citations.
- Preserve returned citation metadata on assistant text blocks instead of dropping it during conversion.
- Support streaming
citations_delta events if possible, or document that only non-streaming citations are supported initially.
- Add serialization/deserialization tests covering:
- request document serializes
citations.enabled = true
- response text block with
char_location citation is preserved
- PDF/page citation and custom content block citation shapes are represented or explicitly handled
This should stay scoped to the Anthropic provider and avoid changing other provider APIs to model fields they do not support.
Alternatives
A downstream raw HTTP call works, but bypasses Rig's provider abstraction, response types, telemetry, and usage handling.
Relevant source/docs:
I'm happy to work on a PR for this
Feature Request
Rig's Anthropic provider supports document content blocks, but it does not currently expose Claude's Messages API citations surface.
Anthropic supports enabling citations on document blocks with:
When enabled, Claude returns citation metadata on response text blocks, including location types such as
char_location,page_location, andcontent_block_location. Streaming responses can also includecitations_delta.Current Rig behavior in
rig-corev0.37.0:crates/rig-core/src/providers/anthropic/completion.rsmodelsContent::Documentwith onlysourceandcache_control.message::Documenthasadditional_params, but the Anthropic conversion currently ignores those provider-specific fields when buildingContent::Document.AssistantContent::Text, which has no place to preserve citation metadata.Related prior work: #1358 added plain text document support for Anthropic, but explicitly did not enable citations.
Motivation
Provider-native citations are useful for document QA, RAG, grading/review workflows, and any application that needs grounded model output with machine-readable links back to source documents.
Without this support, downstream users must bypass Rig and call Anthropic or Anthropic-compatible proxies directly to enable citations and parse the citation-bearing response shape. That loses Rig's normal provider abstraction, response conversion, telemetry, and usage handling.
Proposal
Add Anthropic citation support for document content blocks and responses.
Suggested scope:
citations: { enabled: true }, on supported Anthropic document content blocks.Document::additional_paramsis either intentionally forwarded for Anthropic document fields or provide a typed Anthropic-specific builder/API for citations.citations_deltaevents if possible, or document that only non-streaming citations are supported initially.citations.enabled = truechar_locationcitation is preservedThis should stay scoped to the Anthropic provider and avoid changing other provider APIs to model fields they do not support.
Alternatives
A downstream raw HTTP call works, but bypasses Rig's provider abstraction, response types, telemetry, and usage handling.
Relevant source/docs:
I'm happy to work on a PR for this