adachsoft/ai-model-list-provider-anthropic 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adachsoft/ai-model-list-provider-anthropic

最新稳定版本:v0.2.1

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.4
  • adachsoft/collection ^3.0
  • guzzlehttp/guzzle >= 7.8
  • For the CLI example in bin_dev/anthropic-list-models: vlucas/phpdotenv ^5.6 and adachsoft/console-io ^0.2

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_dev/anthropic-list-models

The script loads .env if present, builds the provider and prints model names.

Changelog

See CHANGELOG.md for the full release history.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固