adachsoft/ai-model-list-provider-anthropic
最新稳定版本:v0.2.0
Composer 安装命令:
composer require adachsoft/ai-model-list-provider-anthropic
包简介
Anthropic (Claude) provider for AdachSoft AI Model List (SPI)
README 文档
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.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-17