providers/anthropic/anthropic library

Modular Anthropic Provider

This library provides a modular implementation of the Anthropic provider

Key Benefits:

  • Single Responsibility: Each module handles one capability
  • Easier Testing: Modules can be tested independently
  • Better Maintainability: Changes isolated to specific modules
  • Cleaner Code: Smaller, focused classes
  • Reusability: Modules can be reused across providers

Usage:

import 'package:llm_dart/providers/anthropic/anthropic.dart';

final provider = AnthropicProvider(AnthropicConfig(
  apiKey: 'your-api-key',
  model: 'claude-sonnet-4-20250514',
));

// Use chat capability
final response = await provider.chat(messages);

Classes

AnthropicChat
Anthropic Chat capability implementation
AnthropicChatResponse
Anthropic chat response implementation
AnthropicClient
Core Anthropic HTTP client shared across all capability modules
AnthropicConfig
Anthropic provider configuration
AnthropicFile
Anthropic-specific file object
AnthropicFileListQuery
Anthropic file list query parameters
AnthropicFileListResponse
Anthropic file list response
AnthropicFiles
Anthropic Files API implementation
AnthropicFileUploadRequest
Anthropic file upload request
AnthropicMCPServer
Anthropic MCP server configuration for the MCP connector feature
AnthropicMCPToolConfiguration
Tool configuration for Anthropic MCP servers
AnthropicMCPToolResult
Anthropic MCP Tool Result content block
AnthropicMCPToolUse
Anthropic MCP Tool Use content block
AnthropicProvider
Anthropic provider implementation

Functions

createAnthropicChatProvider({required String apiKey, String model = 'claude-sonnet-4-20250514', String? systemPrompt, double? temperature, int? maxTokens}) AnthropicProvider
Create an Anthropic provider for chat
createAnthropicProvider({required String apiKey, String? model, String? baseUrl, int? maxTokens, double? temperature, String? systemPrompt, Duration? timeout, bool? stream, double? topP, int? topK, bool? reasoning, int? thinkingBudgetTokens, bool? interleavedThinking}) AnthropicProvider
Create an Anthropic provider with default configuration
createAnthropicReasoningProvider({required String apiKey, String model = 'claude-sonnet-4-20250514', String? systemPrompt, int? thinkingBudgetTokens, bool interleavedThinking = false}) AnthropicProvider
Create an Anthropic provider for reasoning tasks