Search by

adachsoft / model-pricing-source-gemini

Arkadiusz Adach

PSR-18 source for Gemini model pricing data

Package info

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

Issues

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

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-17 20:24 UTC

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, and Priority pricing 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.