Quickstart: providers
attune-rag ships optional LLM provider adapters for Claude and Gemini. Each adapter lazy-imports its SDK, so the core package installs without requiring either. Use list_available() to confirm which providers are ready on your system, then call get_provider() to get a running instance.
from attune_rag.providers import list_available
print(list_available())
# Example output: ['claude', 'gemini']
Prerequisites
attune-raginstalled in your environment- At least one provider SDK installed:
- Claude:
pip install attune-rag[claude] - Gemini:
pip install attune-rag[gemini]
- Claude:
- A valid API key for the provider you want to use
Steps
-
Check which providers are available.
from attune_rag.providers import list_available print(list_available()) # ['claude'] ← only providers whose SDKs are importable appear here -
Instantiate a provider. Pass the provider name to
get_provider(). Supply your API key as a keyword argument; if you omit it, the provider reads from its default environment variable.from attune_rag.providers import get_provider provider = get_provider("claude", api_key="sk-ant-...")If you pass an unrecognised name,
get_provider()raisesValueError: Unknown provider {...}. Known providers: {...}. -
Generate a response.
import asyncio response = asyncio.run( provider.generate("Explain retrieval-augmented generation in one sentence.") ) print(response) # Retrieval-augmented generation combines a retrieval step with a language # model so answers are grounded in specific documents rather than only # parametric knowledge. -
Generate a response with citations (Claude only). Pass a list of
CitationDocumentobjects and a query togenerate_with_citations(). The returnedCitedResponsecontains the answer text and a tuple of claim-level citations.from attune_rag.providers import get_provider from attune_rag.providers.base import CitationDocument provider = get_provider("claude", api_key="sk-ant-...") docs = [ CitationDocument(title="RAG overview", text="RAG grounds LLM outputs in retrieved documents."), ] result = asyncio.run( provider.generate_with_citations(docs, query="What does RAG do?") ) print(result.text) print(result.claim_citations)
Next
Read the LLMProvider protocol reference to learn how to implement your own adapter that works anywhere attune-rag accepts a provider.