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-corecallbacksbaseAsyncCallbackHandleron_llm_new_token
    Methodā—Since v0.1

    on_llm_new_token

    Copy
    on_llm_new_token(
      self,
      token: str,
      *,
      chunk: GenerationChunk | ChatGenerationChunk | 
    View source on GitHub
    None
    =
    None
    ,
    run_id
    :
    UUID
    ,
    parent_run_id
    :
    UUID
    |
    None
    =
    None
    ,
    tags
    :
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    None

    Parameters

    NameTypeDescription
    token*str

    The new token.

    chunkGenerationChunk | ChatGenerationChunk | None
    Default:None

    The new generated chunk, containing content and other information.

    run_id*UUID

    The ID of the current run.

    parent_run_idUUID | None
    Default:None
    tagslist[str] | None
    Default:None
    **kwargsAny
    Default:{}

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

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

    The ID of the parent run.

    The tags.

    Additional keyword arguments.