Toggle Menu
Prev Up Next

# `langchain_nvidia_ai_endpoints.callbacks`.get_usage_callback

langchain_nvidia_ai_endpoints.callbacks.get_usage_callback(price_map: dict = {}, callback: Optional[UsageCallbackHandler] = None) → Generator[UsageCallbackHandler, None, None]

  Get the OpenAI callback handler in a context manager. which conveniently exposes token and cost information.

  Returns

    The OpenAI callback handler.

  Return type

    OpenAICallbackHandler

  Parameters

    - price_map (dict) –

    - callback (Optional[UsageCallbackHandler]) –

  Example

      >>> with get_openai_callback() as cb:
      ...     # Use the OpenAI callback handler