get_bedrock_anthropic_callback#

langchain_community.callbacks.manager.get_bedrock_anthropic_callback() Generator[BedrockAnthropicTokenUsageCallbackHandler, None, None][source]#

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

Returns:

The Bedrock anthropic callback handler.

Return type:

BedrockAnthropicTokenUsageCallbackHandler

Example

>>> with get_bedrock_anthropic_callback() as cb:
...     # Use the Bedrock anthropic callback handler

Examples using get_bedrock_anthropic_callback