Documentation Index
Fetch the complete documentation index at: https://docs.doclo.ai/llms.txt
Use this file to discover all available pages before exploring further.
Anthropic provides Claude models with excellent document understanding and structured output capabilities.
Installation
npm install @doclo/providers-llm
Basic Setup
Via OpenRouter (Recommended)
import { createVLMProvider } from '@doclo/providers-llm';
const provider = createVLMProvider({
provider: 'anthropic',
model: 'anthropic/claude-sonnet-4.5',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
});
Native API
const provider = createVLMProvider({
provider: 'anthropic',
model: 'claude-sonnet-4.5',
apiKey: process.env.ANTHROPIC_API_KEY!
});
Available Models
| Model | Context | Reasoning | Best For |
|---|
claude-opus-4.5 | 200k | Yes | Complex extraction |
claude-sonnet-4.5 | 200k | Yes | Balanced performance |
claude-haiku-4.5 | 200k | Yes | Fast, cost-effective |
claude-opus-4 | 200k | Yes | Previous generation |
claude-sonnet-4 | 200k | Yes | Previous generation |
OpenRouter Model IDs
When using OpenRouter, prefix models with anthropic/:
// OpenRouter
model: 'anthropic/claude-sonnet-4.5'
// Native
model: 'claude-sonnet-4.5'
Configuration Options
createVLMProvider({
provider: 'anthropic',
model: string, // Model ID
apiKey: string, // API key
via?: 'openrouter', // Access method
baseUrl?: string, // Custom endpoint
limits?: {
maxFileSize?: number, // Max file size (bytes)
requestTimeout?: number, // Timeout (ms)
maxJsonDepth?: number // Max JSON nesting
}
})
Capabilities
| Feature | Support |
|---|
| Images | Yes (PNG, JPEG, WebP, GIF) |
| PDFs | Yes (up to 100 pages) |
| Structured Output | Yes (tool calling / output_format) |
| Reasoning | Yes (extended thinking) |
| Streaming | Yes |
Images
Claude requires base64-encoded images (URLs are downloaded automatically):
// Via Base64 (preferred)
{
images: [{
base64: 'data:image/jpeg;base64,...',
mimeType: 'image/jpeg'
}]
}
Supported formats: PNG, JPEG, WebP, GIF (max 5MB per image, 8000x8000 max).
PDFs
// Via Base64
{
pdfs: [{
base64: 'data:application/pdf;base64,...'
}]
}
// Via Files API (native only)
{
pdfs: [{
fileId: 'file_abc123'
}]
}
PDF limits: 32MB per file, 100 pages for full visual analysis.
Extended Thinking
Claude models support extended thinking for complex reasoning:
import { createFlow, extract } from '@doclo/flows';
const flow = createFlow()
.step('extract', extract({
provider: createVLMProvider({
provider: 'anthropic',
model: 'anthropic/claude-sonnet-4.5',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
}),
schema: complexSchema,
reasoning: {
enabled: true,
effort: 'high'
}
}))
.build();
Reasoning is configured via max_tokens (OpenRouter) or budget_tokens (native):
| Effort | OpenRouter | Native |
|---|
| low | 20% of max_tokens | 1024 tokens min |
| medium | 50% of max_tokens | Calculated |
| high | 80% of max_tokens | Up to 32000 tokens |
Prompt Caching
Claude supports prompt caching for repeated extractions with the same schema:
// Caching is automatic when using OpenRouter
// Add cache_control to text blocks for optimal caching
Cache metrics are returned in the response:
cacheCreationInputTokens: Tokens written to cache
cacheReadInputTokens: Tokens read from cache
Structured Output
Claude 4.5 models support native structured output via output_format. Older models use tool calling:
// Automatically handled - SDK detects model version
const provider = createVLMProvider({
provider: 'anthropic',
model: 'anthropic/claude-sonnet-4.5',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
});
Model support:
- Sonnet 4.5+: Native
output_format with json_schema
- Opus 4.1+: Native
output_format with json_schema
- Haiku: Tool calling fallback
Production Setup
import { buildLLMProvider } from '@doclo/providers-llm';
const provider = buildLLMProvider({
providers: [
{
provider: 'anthropic',
model: 'anthropic/claude-sonnet-4.5',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
},
{
provider: 'anthropic',
model: 'anthropic/claude-haiku-4.5',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
}
],
maxRetries: 2,
retryDelay: 1000,
useExponentialBackoff: true
});
Pricing
Via OpenRouter (approximate):
| Model | Input (per 1k) | Output (per 1k) |
|---|
| claude-opus-4.5 | $0.015 | $0.075 |
| claude-sonnet-4.5 | $0.003 | $0.015 |
| claude-haiku-4.5 | $0.0008 | $0.004 |
Example: Contract Analysis
import { createFlow, extract } from '@doclo/flows';
import { createVLMProvider } from '@doclo/providers-llm';
const provider = createVLMProvider({
provider: 'anthropic',
model: 'anthropic/claude-sonnet-4.5',
apiKey: process.env.OPENROUTER_API_KEY!,
via: 'openrouter'
});
const contractSchema = {
type: 'object',
properties: {
parties: {
type: 'array',
items: { type: 'string' }
},
effectiveDate: { type: 'string' },
terminationDate: { type: 'string' },
keyTerms: {
type: 'array',
items: {
type: 'object',
properties: {
term: { type: 'string' },
description: { type: 'string' }
}
}
}
}
};
const flow = createFlow()
.step('extract', extract({
provider,
schema: contractSchema,
reasoning: { enabled: true, effort: 'medium' }
}))
.build();
const result = await flow.run({
base64: 'data:application/pdf;base64,...'
});
Next Steps