ReadonlyproviderProvider identifier (e.g., 'anthropic', 'openai')
ReadonlymodelModel identifier (e.g., 'claude-sonnet-4', 'gpt-4o')
ReadonlycapabilitiesCapabilities this model supports
Protected ReadonlyloggerLogger for request/response logging
Protected ReadonlyconfigConfiguration for the adapter
Check if this adapter supports a specific capability.
The capability to check for
True if the capability is supported
ProtectedlogLog details about an outgoing request. Sanitizes sensitive information before logging.
The completion request to log
ProtectedlogLog details about a received response.
The completion response to log
ProtectedtransformTransform a provider-specific error into a standardized ModelError.
Maps common error patterns to appropriate error codes:
The original error from the provider
A standardized ModelError
Validate adapter configuration.
Checks that required configuration fields are present and valid. Concrete adapters may override to add provider-specific validation.
Ok if valid, ConfigError if invalid
Send a completion request to the model. Must be implemented by concrete adapter classes.
The completion request
Result with response or ModelError
Stream a completion request from the model. Must be implemented by concrete adapter classes.
The completion request
Count tokens in text using the unified TokenEstimator.
This provides a reasonable estimate for most use cases. Concrete adapters may override this with provider-specific tokenizers.
Text to count tokens for
Approximate token count
Ollama model adapter for local model inference.