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
JavaScriptlangchainindexModelRequest
Interfaceā—Since v1.2

ModelRequest

Configuration for modifying a model call at runtime. All fields are optional and only provided fields will override defaults.

Copy
interface ModelRequest

Properties

View source on GitHub
property
messages: BaseMessage<MessageStructure<MessageToolSet>, MessageType>[]
property
model: AgentLanguageModelLike
property
modelSettings: Record<string, unknown>
property
responseFormat: TResponseFormat
property
runtime: Runtime<TContext>
property
state: TState & AgentBuiltInState
property
systemMessage: SystemMessage
property
toolChoice: "required" | "auto" | "none" | __type
property
tools: ClientTool | ServerTool[]
deprecatedproperty
systemPrompt: string

Additional settings to bind to the model when preparing it for invocation. These settings are applied via bindTools() and can include parameters like headers, container, etc. The model is re-bound on each request, so these settings can vary per invocation.

The tool response format.

If "content" then the output of the tool is interpreted as the contents of a ToolMessage. If "content_and_artifact" then the output is expected to be a two-tuple corresponding to the (content, artifact) of a ToolMessage.

The runtime context containing metadata, signal, writer, interrupt, etc.

The current agent state (includes both middleware state and built-in state).

The system message for this step. If no systemPrompt was provided, when createAgent was initialized, an empty system message will be used.

Tool choice configuration (model-specific format). Can be one of:

  • "auto": means the model can pick between generating a message or calling one or more tools.
  • "none": means the model will not call any tool and instead generates a message.
  • "required": means the model must call one or more tools.
  • { type: "function", function: { name: string } }: The model will use the specified function.

The system message string for this step.

Copy
modelSettings: {
  headers: { "anthropic-beta": "code-execution-2025-08-25" },
  container: "container_abc123"
}
Copy
wrapModelCall: async (request, handler) => {
  return handler({
    ...request,
    systemMessage: request.systemMessage.concat("something")
  });
}
Copy
wrapModelCall: async (request, handler) => {
  return handler({
    ...request,
    systemMessage: request.systemMessage.concat(
      new SystemMessage({
        content: [{
          type: "text",
          text: "something",
          cache_control: { type: "ephemeral", ttl: "1m" }
        }],
      })
    ),
  });
}