Adding a custom cost
- Python
- TypeScript
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
- Python
- TypeScript
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
- Python
- TypeScript
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
- Python
- TypeScript
You can calculate costs for a project by using our
calls_query and adding include_costs=True with a little bit of setup.