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

    on_llm_new_token

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

    Parameters

    NameTypeDescription
    token*str | list[str | dict[str, Any]]

    The new token, or a list of content blocks.

    chunkGenerationChunk | ChatGenerationChunk | None
    Default:None
    run_id*UUID
    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 new generated chunk, containing content and other information.

    The ID of the current run.

    The ID of the parent run.

    The tags.

    Additional keyword arguments.