adachsoft / model-pricing-source-gemini
PSR-18 source for Gemini model pricing data
Package info
gitlab.com/a.adach/model-pricing-source-gemini
pkg:composer/adachsoft/model-pricing-source-gemini
Requires
- php: ^8.3
- adachsoft/model-pricing-contracts: ^0.4
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
Requires (Dev)
- adachsoft/model-pricing-lib: ^0.1.0
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- guzzlehttp/psr7: ^2.7
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^12.5
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-17 19:24:25 UTC
README
A framework-independent PriceSourceInterface adapter that retrieves and parses Google's official Gemini pricing page (https://aistudio.google.com/docs/pricing.md). It uses PSR-18 for HTTP requests and PSR-17 to create requests.
Features
- Reads linked model IDs and the
Standard,Batch,Flex, andPrioritypricing tabs. - Emits Paid Tier text-token input, output, and cached-input prices per million tokens.
- Preserves prompt-length tiers and scheduled price changes as effective-dated price sheets.
- Ignores non-token charges such as audio, image, video, grounding, and storage prices.
Requirements
- PHP 8.3 or later.
- A PSR-18 HTTP client implementation.
- A PSR-17 request factory implementation.
Installation
composer require adachsoft/model-pricing-source-gemini
Usage
Construct GeminiPriceSource with a GeminiPricingPageFetcher, configured with your PSR-18 client and PSR-17 request factory. Call fetchPriceSheets() with the UTC timestamp at which the pricing page was fetched. See the usage example for a complete setup.
Pricing data notes
A model section is retained when at least one input or output row contains a text-token price; linked model aliases in that section receive the same prices. Prompt-length prices such as prompts <= 200k tokens and prompts > 200k tokens become short and long context-tier components with a threshold of 200000 input tokens. Scheduled prices create future sheets at their stated UTC start dates, while unchanged components remain present in those sheets.
The audio-only Gemini 3.5 Live Translate Preview section (gemini-3.5-live-translate-preview) is omitted because it has no text-token input or output price. In mixed-modality sections, text-token prices are included while audio-only prices are ignored.