Search by

adachsoft / model-pricing-source-anthropic

Arkadiusz Adach

Anthropic model pricing source for model-pricing-lib

Package info

gitlab.com/a.adach/model-pricing-source-anthropic

Issues

pkg:composer/adachsoft/model-pricing-source-anthropic

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-17 19:25 UTC

This package is auto-updated.

Last update: 2026-11-17 18:25:23 UTC


README

A PriceSourceInterface implementation that retrieves Anthropic's official Markdown pricing page and converts its model prices into validated price sheets for model-pricing-lib.

Features

  • Parses standard, batch-processing, and fast-mode prices, including cache prices and context tiers.
  • Represents eligible US inference prices as separate pricing components.
  • Uses decimal-string arithmetic instead of binary floating-point calculations.
  • Fetches pricing through injected PSR-18 and PSR-17 implementations.

Installation

composer require adachsoft/model-pricing-source-anthropic

Requirements

  • PHP 8.3 or later
  • The BCMath PHP extension
  • A PSR-18 HTTP client and a PSR-17 request factory provided by your application

Usage

Create a PSR-18 client and PSR-17 request factory using your application's HTTP libraries, then pass them into the source:

$source = new AnthropicPriceSource(
    new AnthropicPricingPageFetcher($httpClient, $requestFactory),
);

$priceSheets = $source->fetchPriceSheets(new DateTimeImmutable());

See the complete usage example for imports and exception handling. The source downloads the official Anthropic pricing page when fetching price sheets.

Development

The test suite uses a Markdown fixture and fake HTTP responses; it does not make network requests.