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-corelanguage_modelschat_modelsBaseChatModelagenerate
    Method●Since v0.1

    agenerate

    Copy
    agenerate(
      self,
      messages: list[list[BaseMessage]],
      stop: list
    View source on GitHub
    [
    str
    ]
    |
    None
    =
    None
    ,
    callbacks
    :
    Callbacks
    =
    None
    ,
    *
    ,
    tags
    :
    list
    [
    str
    ]
    |
    None
    =
    None
    ,
    metadata
    :
    dict
    [
    str
    ,
    Any
    ]
    |
    None
    =
    None
    ,
    run_name
    :
    str
    |
    None
    =
    None
    ,
    run_id
    :
    uuid
    .
    UUID
    |
    None
    =
    None
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    LLMResult

    Parameters

    NameTypeDescription
    messages*list[list[BaseMessage]]

    List of list of messages.

    stoplist[str] | None
    Default:None

    Stop words to use when generating.

    Model output is cut off at the first occurrence of any of these substrings.

    callbacksCallbacks
    Default:None
    tagslist[str] | None
    Default:None
    metadatadict[str, Any] | None
    Default:None
    run_namestr | None
    Default:None
    run_iduuid.UUID | None
    Default:None
    **kwargsAny
    Default:{}

    Asynchronously pass a sequence of prompts to a model and return generations.

    This method should make use of batched calls for models that expose a batched API.

    Use this method when you want to:

    1. Take advantage of batched calls,
    2. Need more output from the model than just the top generated value,
    3. Are building chains that are agnostic to the underlying language model type (e.g., pure text completion models vs chat models).

    Callbacks to pass through.

    Used for executing additional functionality, such as logging or streaming, throughout generation.

    The tags to apply.

    The metadata to apply.

    The name of the run.

    The ID of the run.

    Arbitrary additional keyword arguments.

    These are usually passed to the model provider API call.