Search by

adachsoft / model-pricing-source-openai

Arkadiusz Adach

Price source for adachsoft/model-pricing-lib that reads the official OpenAI API pricing page.

Package info

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

Issues

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

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

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

This package is auto-updated.

Last update: 2026-11-17 18:01:45 UTC


README

A price source for adachsoft/model-pricing-lib. It fetches OpenAI's public API pricing page and its referenced pricing bundle, validates the listed model rates, and returns immutable price sheets in USD.

Features

  • Supports standard, batch, flex, priority, and ultrafast service tiers.
  • Parses short- and long-context pricing, including legacy table rows.
  • Preserves decimal prices exactly and rejects incomplete or inconsistent pricing data instead of returning partial results.
  • Uses PSR-18 HTTP clients and PSR-17 request factories.

Requirements

  • PHP 8.3 or later
  • The BCMath and JSON PHP extensions
  • A PSR-18 HTTP client and a PSR-17 request factory

Installation

composer require adachsoft/model-pricing-source-openai

Usage

Create an OpenAiPriceSource with a PSR-18 client and PSR-17 request factory, then call fetchPriceSheets() to retrieve validated USD price sheets. See the fetch pricing example for a complete example.

Documentation