adachsoft / ai-model-list-provider-anthropic
Anthropic (Claude) provider for AdachSoft AI Model List (SPI)
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/adachsoft/ai-model-list-provider-anthropic
Requires
- php: >=8.3
- adachsoft/ai-model-list: ^0.3.0
- adachsoft/collection: >=2.1
- adachsoft/console-io: ^0.1.0
- guzzlehttp/guzzle: >=7.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^1.11
- phpunit/phpunit: >=12.0
This package is not auto-updated.
Last update: 2025-10-21 18:38:38 UTC
README
Anthropic (Claude) provider for AdachSoft AI Model List (SPI).
Requirements
- PHP >= 8.3
- adachsoft/ai-model-list ^0.3.0
- adachsoft/collection >= 2.1
- guzzlehttp/guzzle >= 7.8
- (CLI example) vlucas/phpdotenv ^5.6, adachsoft/console-io ^0.1.0
Installation
Install the provider as a regular Composer dependency:
composer require adachsoft/ai-model-list-provider-anthropic
Optional (recommended): enable Composer plugin for autodiscovery by installing adachsoft/ai-model-list-plugin in your application. The plugin will detect this provider using the entry file declared in this package (resources/ai-model-list.php) without code changes in your app.
composer require adachsoft/ai-model-list-plugin "^1.0"
If your Composer setup requires explicit allow-plugins, enable it for the plugin:
{
"config": {
"allow-plugins": {
"adachsoft/ai-model-list-plugin": true
}
}
}
Configuration
This provider requires only an API key and uses a fixed Anthropic API endpoint.
Required:
- ANTHROPIC_API_KEY
Optional:
- ANTHROPIC_API_VERSION (default: 2023-06-01)
- ANTHROPIC_TIMEOUT (default: 10 seconds)
Note: Base URL configuration is not supported. The endpoint is hardcoded to https://api.anthropic.com.
Quick Start (without autodiscovery)
use AdachSoft\AIModelList\PublicApi\Builder\AiModelCatalogFacadeBuilder;
use AdachSoft\AIModelListProviderAnthropic\AnthropicSpiProvider;
use AdachSoft\AIModelListProviderAnthropic\Config\AnthropicProviderConfig;
use AdachSoft\AIModelListProviderAnthropic\Http\GuzzleAnthropicHttpClient;
use AdachSoft\AIModelListProviderAnthropic\Mapper\AnthropicToSpiModelMapper;
$config = new AnthropicProviderConfig(
apiKey: 'YOUR_API_KEY',
apiVersion: '2023-06-01',
timeout: 10.0,
);
$http = new GuzzleAnthropicHttpClient($config);
$mapper = new AnthropicToSpiModelMapper();
$provider = new AnthropicSpiProvider($http, $mapper);
$facade = (new AiModelCatalogFacadeBuilder())
->withSpiProvider($provider)
->build();
$models = $facade->listModels('anthropic');
Autodiscovery (with Composer plugin)
When adachsoft/ai-model-list-plugin is installed and allowed, it scans installed packages and generates a registry. This package exposes an entry file at resources/ai-model-list.php that registers the provider factory:
- AdachSoft\AIModelListProviderAnthropic\Factory\AnthropicProviderFactory
At runtime, the registry reader (from the plugin) will provide instances of this provider to be passed into AiModelCatalogFacadeBuilder.
CLI Example
Set environment variables (at least ANTHROPIC_API_KEY) and run:
php bin/anthropic-list-models
The script loads .env if present, builds the provider and prints model names.
Changelog (excerpt)
- v0.2.0
- Breaking: removed support for custom base URL (ANTHROPIC_BASE_URL). Endpoint is fixed to https://api.anthropic.com.
- Added: SPI factory (AnthropicProviderFactory) and autodiscovery entry file (resources/ai-model-list.php).
- Changed: require adachsoft/ai-model-list ^0.3.0.
- v0.1.0
- Initial release.