LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
  • Tools
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Compat
  • Event
  • Llms
  • Profile
  • Stream
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Uuid
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn MemoryTools
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsCompatEventLlmsProfileStreamStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesUuidVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/corecallbacksmanagerCallbackManager
Class●Since v1.0

CallbackManager

Copy
class CallbackManager

Bases

BaseCallbackManager

Constructors

Properties

Methods

Inherited fromBaseCallbackManager

Methods

MaddHandlerMremoveHandlerMsetHandlerMsetHandlers
View source on GitHub

Example

constructor
constructor
property
_parentRunId: string
property
handlers: BaseCallbackHandler[]
property
inheritableHandlers: BaseCallbackHandler[]
property
inheritableMetadata: Record<string, unknown>
property
inheritableTags: string[]
property
metadata: Record<string, unknown>
property
name: string
property
tags: string[]
method
addHandler
method
addMetadata
method
addTags
method
copy→ BaseCallbackHandler
method
getParentRunId→ string | undefined
method
handleChainStart→ any
method
handleChatModelStart→ any
method
handleCustomEvent→ any
method
handleLLMStart→ any
method
handleRetrieverStart→ any
method
handleToolStart→ any
method
removeHandler
method
removeMetadata
method
removeTags
method
setHandler
method
setHandlers
method
_configureSync→ CallbackManager | undefined
method
configure→ CallbackManager | undefined
method
fromHandlers→ CallbackManager

Gets the parent run ID, if any.

Called at the start of a Chain run, with the chain name and inputs and the run ID.

Called at the start of a Chat Model run, with the prompt(s) and the run ID.

Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.

Called at the start of a Tool run, with the tool name and input and the run ID.

Copy
const prompt = PromptTemplate.fromTemplate("What is the answer to {question}?");

// Example of using LLMChain with OpenAI and a simple prompt
const chain = new LLMChain({
  llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0.9 }),
  prompt,
});

// Running the chain with a single question
const result = await chain.call({
  question: "What is the airspeed velocity of an unladen swallow?",
});
console.log("The answer is:", result);