pricing
ipw.cost.pricing
¶
Pricing tables and cost calculation for LLM API providers.
All prices are per 1M tokens in USD unless otherwise noted.
calculate_cost(provider, model, input_tokens, output_tokens)
¶
Calculate API cost in USD for a given provider, model, and token usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Provider name (openai, anthropic, gemini, google). |
required |
model
|
str
|
Model identifier as used in the provider's API. |
required |
input_tokens
|
int
|
Number of input / prompt tokens. |
required |
output_tokens
|
int
|
Number of output / completion tokens. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Estimated cost in USD. Returns 0.0 if the provider or model is |
float
|
not found in the pricing tables. |