adachsoft/ai-model-list-provider-anthropic

Anthropic (Claude) provider for AdachSoft AI Model List (SPI)

Maintainers

Package info

gitlab.com/a.adach/AIModelListProviderAnthropic

Issues

pkg:composer/adachsoft/ai-model-list-provider-anthropic

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

v0.3.0 2026-08-15 08:45 UTC

This package is auto-updated.

Last update: 2026-08-15 06:46:01 UTC


README

Anthropic (Claude) provider for AdachSoft AI Model List (SPI).

Requirements

  • PHP >= 8.3
  • ext-dom
  • adachsoft/ai-model-list ^0.5
  • 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');

Pricing enrichment

Optional metadata enricher that scrapes Anthropic public pricing HTML and attaches pricing components to Anthropic models. It is independent from the model list provider and can be registered separately.

use AdachSoft\AIModelList\PublicApi\Builder\AiModelCatalogFacadeBuilder;
use AdachSoft\AIModelListProviderAnthropic\Pricing\Factory\AnthropicPricingEnricherFactory;

$facade = (new AiModelCatalogFacadeBuilder())
    ->withSpiProvider($anthropicProvider)
    ->withEnricher(AnthropicPricingEnricherFactory::create())
    ->build();

Important:

  • Pricing data comes from HTML scraping and may be unavailable or outdated.
  • Do not use scraped prices as a financial billing source without independent verification.
  • When pricing cannot be resolved, pricing is null — the catalog continues to work without errors.
  • MVP does not detect pricing conditions (tier, batch, context length); all rates are unconditional.

Live integration test (optional, excluded from the default suite):

vendor/bin/phpunit --group external

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.

Architecture and coding standards

This project follows a Feature-First Package Layout. Before adding capabilities, read the architectural decisions:

Related:

Changelog

See CHANGELOG.md for the full release history.