compass.utilities.costs.cost_for_model#
- cost_for_model(model_name, prompt_tokens, completion_tokens)[source]#
Compute the API costs for a model given the token usage
- Parameters:
model_name (
str) – Name of the model. Needs to be registered as a key inLLM_COST_REGISTRYfor this method to return a non-zero value.prompt_tokens (
int) – Number of prompt and completion tokens used, respectively.completion_tokens (
int) – Number of prompt and completion tokens used, respectively.
- Returns:
float– Total cost based on the token usage.