AnthropicProvider class

Anthropic provider implementation

This provider implements multiple capability interfaces following the modular architecture pattern. It supports:

  • ChatCapability: Core chat functionality
  • ModelListingCapability: Model discovery and information

API Documentation:

This provider delegates to specialized capability modules for different functionalities, maintaining clean separation of concerns.

Implemented types

Constructors

AnthropicProvider.new(AnthropicConfig config)

Properties

config AnthropicConfig
final
hashCode int
The hash code for this object.
no setterinherited
providerName String
Get provider name
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedCapabilities Set<LLMCapability>
Set of capabilities this provider supports
no setteroverride

Methods

chat(List<ChatMessage> messages) Future<ChatResponse>
Sends a chat request to the provider with a sequence of messages.
override
chatStream(List<ChatMessage> messages, {List<Tool>? tools}) Stream<ChatStreamEvent>
Sends a streaming chat request to the provider
override
chatWithTools(List<ChatMessage> messages, List<Tool>? tools) Future<ChatResponse>
Sends a chat request to the provider with a sequence of messages and tools.
override
countTokens(List<ChatMessage> messages, {List<Tool>? tools}) Future<int>
Count tokens for messages using Anthropic's API
deleteFile(String fileId) Future<FileDeleteResponse>
Delete a file
override
deleteFiles(List<String> fileIds) Future<Map<String, bool>>
Batch delete multiple files
fileExists(String fileId) Future<bool>
Check if a file exists
getFileContent(String fileId) Future<List<int>>
Get file content
override
getFileContentAsString(String fileId) Future<String>
Get file content as string (for text files)
getModel(String modelId) Future<AIModel?>
Get information about a specific model
getTotalStorageUsed() Future<int>
Get total storage used by all files
listFiles([FileListQuery? query]) Future<FileListResponse>
List files
override
listModels({String? beforeId, String? afterId, int limit = 20}) Future<List<AIModel>>
List available models from Anthropic API
memoryContents() Future<List<ChatMessage>?>
Get current memory contents if provider supports memory
override
models() Future<List<AIModel>>
Get available models from the provider
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
retrieveFile(String fileId) Future<FileObject>
Retrieve file metadata
override
summarizeHistory(List<ChatMessage> messages) Future<String>
Summarizes a conversation history into a concise 2-3 sentence summary
override
supports(LLMCapability capability) bool
Check if this provider supports a specific capability
override
toString() String
A string representation of this object.
inherited
uploadFile(FileUploadRequest request) Future<FileObject>
Upload a file
override
uploadFileFromBytes(List<int> bytes, {String? filename}) Future<FileObject>
Upload file from bytes with automatic filename

Operators

operator ==(Object other) bool
The equality operator.
inherited