Skip to main content

Module cost

Module cost 

Source
Expand description

Token cost estimation for AI vision providers.

Both OpenAI and Anthropic charge tokens for image inputs based on image dimensions. This module implements the public token-counting formulas so SHIFT can report estimated savings.

Structs§

ImageMetrics
Per-image before/after metrics for the report.
TokenEstimate
Estimated token counts for a single image across providers.
TokenSavings
Aggregate token savings across all images.

Functions§

anthropic_tokens
Anthropic vision token count for standard-resolution models.
estimate_tokens
Estimate tokens for an image at given dimensions.
openai_tokens
OpenAI vision token count for detail: high.
openai_tokens_low
Fixed token count for OpenAI detail: low.