Skip to main content

Adding a custom cost

You can add a custom cost by using the add_cost method. The three required fields are llm_id, prompt_token_cost, and completion_token_cost. llm_id is the name of the LLM (e.g. gpt-4o). prompt_token_cost and completion_token_cost are cost per token for the LLM (if the LLM prices were specified inper million tokens, make sure to convert the value). You can also set effective_date to a datetime, to make the cost effective at a specific date, this defaults to the current date.

Querying for costs

You can query for costs by using the query_costs method. There are a few ways to query for costs, you can pass in a singular cost id, or a list of LLM model names.

Purging a custom cost

You can purge a custom cost by using the purge_costs method. You pass in a list of cost ids, and the costs with those ids are purged.

Calculating costs for a Project

You can calculate costs for a project by using our calls_query and adding include_costs=True with a little bit of setup.

Setting up a custom model with custom costs

Try our cookbook for Setting up costs with a custom model.

Try in Colab