genai_get_pricing function retrieves the pricing information for a specific AI model. It returns a dynamic object containing the input token price and output token price per million tokens, which you can use for cost calculations and budgeting.
You can use this function to display pricing information, create cost calculators, audit pricing data, or understand the cost structure of different AI models.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.Splunk SPL users
Splunk SPL users
In Splunk SPL, you would typically use a lookup table to retrieve pricing information by model name.
ANSI SQL users
ANSI SQL users
In ANSI SQL, you would join with a pricing table to get model costs.
Usage
Syntax
Parameters
- model (string, required): The name of the AI model (for example, ‘gpt-4’, ‘claude-3-opus-20240229’, ‘gpt-3.5-turbo’).
Returns
Returns a dynamic object containing pricing information with the following structure:Use case examples
- Log analysis
- OpenTelemetry traces
- Security logs
Display pricing information for models being used to help teams understand cost implications.QueryRun in PlaygroundOutput
This query shows which models are being used and their associated pricing, helping teams make informed decisions.
| model_name | pricing | request_count |
|---|---|---|
| gpt-4 | {"input_price_per_million": 30.0, "output_price_per_million": 60.0} | 450 |
| gpt-3.5-turbo | {"input_price_per_million": 0.5, "output_price_per_million": 1.5} | 1250 |
List of related functions
- genai_cost: Calculates total cost for a conversation. Use this for actual cost calculation after retrieving pricing information.
- genai_input_cost: Calculates input token cost. This function uses genai_get_pricing internally to determine input costs.
- genai_output_cost: Calculates output token cost. This function uses genai_get_pricing internally to determine output costs.
- genai_estimate_tokens: Estimates token count. Combine with pricing information to predict costs before making API calls.