get_openai_callback() -> Generator[OpenAICallbackHandler, None, None]Get the OpenAI callback handler in a context manager. which conveniently exposes token and cost information.
Example:
with get_openai_callback() as cb: ... # Use the OpenAI callback handler