langchain.callbacks.openai_info.get_openai_token_cost_for_model

langchain.callbacks.openai_info.get_openai_token_cost_for_model(model_name: str, num_tokens: int, is_completion: bool = False) float[source]

Get the cost in USD for a given model and number of tokens.

Parameters
  • model_name – Name of the model

  • num_tokens – Number of tokens.

  • is_completion – Whether the model is used for completion or not. Defaults to False.

Returns

Cost in USD.