LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corecallbacksbaseAsyncCallbackHandler
    Class●Since v0.1

    AsyncCallbackHandler

    Base async callback handler.

    Copy
    AsyncCallbackHandler()

    Bases

    BaseCallbackHandler

    Used in Docs

    • Bedrock integration

    Methods

    method
    on_llm_start

    Run when the model starts running.

    Warning

    This method is called for non-chat models (regular text completion LLMs). If you're implementing a handler for a chat model, you should use on_chat_model_start instead.

    method
    on_chat_model_start

    Run when a chat model starts running.

    Warning

    This method is called for chat models. If you're implementing a handler for a non-chat model, you should use on_llm_start instead.

    method
    on_llm_new_token

    Run on new output token. Only available when streaming is enabled.

    For both chat models and non-chat models (legacy text completion LLMs).

    method
    on_llm_end

    Run when the model ends running.

    method
    on_llm_error

    Run when LLM errors.

    method
    on_chain_start

    Run when a chain starts running.

    method
    on_chain_end

    Run when a chain ends running.

    method
    on_chain_error

    Run when chain errors.

    method
    on_tool_start

    Run when the tool starts running.

    method
    on_tool_end

    Run when the tool ends running.

    method
    on_tool_error

    Run when tool errors.

    method
    on_text

    Run on an arbitrary text.

    method
    on_retry

    Run on a retry event.

    method
    on_agent_action

    Run on agent action.

    method
    on_agent_finish

    Run on the agent end.

    method
    on_retriever_start

    Run on the retriever start.

    method
    on_retriever_end

    Run on the retriever end.

    method
    on_retriever_error

    Run on retriever error.

    method
    on_custom_event

    Override to define a handler for custom events.

    Inherited fromBaseCallbackHandler

    Attributes

    Araise_error: bool
    —

    Whether to raise an error if an exception occurs.

    Arun_inline: boolAignore_llm: bool
    —

    Whether to ignore LLM callbacks.

    Aignore_retry: bool
    —

    Whether to ignore retry callbacks.

    Aignore_chain: bool
    —

    Whether to ignore chain callbacks.

    Aignore_agent: bool
    —

    Whether to ignore agent callbacks.

    Aignore_retriever: bool
    —

    Whether to ignore retriever callbacks.

    Aignore_chat_model: bool
    —

    Whether to ignore chat model callbacks.

    Aignore_custom_event: bool
    —

    Ignore custom event.

    View source on GitHub