> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-docs-zh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 模型

> 配置 Deep Agents 的模型提供者和参数

Deep Agents 与支持 [工具调用](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models.md#工具调用) 的任何 [LangChain 对话模型](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models.md) 都兼容。

## 支持的模型

:::python
以 `provider:model` 格式指定模型（例如 `google_genai:gemini-3.6-flash`、`openai:gpt-5.4` 或 `anthropic:claude-sonnet-4-6`）。提供者前缀选择 LangChain 集成，冒号后的所有内容都会传递给该提供者作为模型标识符。有关有效的提供者字符串，请参阅 @\[`init_chat_model`] 的 `model_provider` 参数。有关提供者特定的配置，请参阅 [对话模型集成](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat.md)。
:::

:::js
以 `provider:model` 格式指定模型（例如 `google:gemini-3.6-flash`、`openai:gpt-5.4` 或 `anthropic:claude-sonnet-4-6`）。提供者前缀选择 LangChain 集成，冒号后的所有内容都会传递给该提供者作为模型标识符。有关有效的提供者字符串，请参阅 @\[`initChatModel`]。有关提供者特定的配置，请参阅 [对话模型集成](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat.md)。
:::

模型标识符必须与提供者期望的格式匹配。一些提供者使用简单的名称，如 `gpt-5.5`；其他提供者使用命名空间 ID 或部署路径，如 `zai-org/GLM-5.2`，因此完整的 Deep Agents 字符串将是 `baseten:zai-org/GLM-5.2`。检查提供者的模型目录或集成文档以获取当前标识符。

### 推荐的模型

这些模型在 [Deep Agents 评估套件](https://github.com/langchain-ai/deepagents/tree/main/libs/evals#readme) 上表现良好，该套件测试基本智能体操作。通过这些评估是必要的，但不是在更长时间、更复杂的任务上获得良好性能的充分条件。

| 提供者 | 模型 |
| - | - |
| [Google](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/google.md) | `gemini-3.1-pro-preview`, `gemini-3.6-flash` |
| [OpenAI](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/openai.md) | `gpt-5.5`, `gpt-5.4` |
| [Anthropic](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/anthropic.md) | `claude-opus-4-8`, `claude-opus-4-7`, `claude-opus-4-6` |
| Open-weight | `GLM-5.2`, `Kimi-K2.7 Code`, `MiniMax-M3` |

:::python
Open-weight 模型可以通过 [Baseten](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/baseten.md)、[Fireworks](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat/fireworks.md)、[OpenRouter](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/openrouter.md) 和 [Ollama](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/ollama.md) 等提供者获得。
:::

:::js
Open-weight 模型可以通过 [OpenRouter](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat/openrouter.md) 和 [Ollama](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat/ollama.md) 等提供者获得。
:::

### 模型评估

[Deep Agents 评估套件](https://github.com/langchain-ai/deepagents/tree/main/libs/evals#readme) 测试流行的模型：

| 模型 | 整体表现 | 文件操作 | 检索 | 工具调用 | 内存 | 对话 | 摘要 |
| :- | -: | -: | -: | -: | -: | -: | -: |
| google\_genai:gemini-3.6-flash | [82%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | **[90%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | [54%](https://github.com/langchain-ai/deepagents/actions/runs/25290479270) | [38%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) |
| openai:gpt-5.4 | [18%](https://github.com/langchain-ai/deepagents/actions/runs/24906955930) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583)** | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583)** | [18%](https://github.com/langchain-ai/deepagents/actions/runs/24906955930) | [51%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583) | [38%](https://github.com/langchain-ai/deepagents/actions/runs/24425363630) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583)** |
| openai:gpt-5.5 | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | [92%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | [84%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | [64%](https://github.com/langchain-ai/deepagents/actions/runs/25345307822) | **[52%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) |
| anthropic:claude-opus-4-6 | [26%](https://github.com/langchain-ai/deepagents/actions/runs/24906955930) | [92%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583)** | [26%](https://github.com/langchain-ai/deepagents/actions/runs/24906955930) | **[69%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583)** | [22%](https://github.com/langchain-ai/deepagents/actions/runs/24363491527) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/24172638583)** |
| anthropic:claude-opus-4-7 | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | [82%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | — | [48%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** |
| baseten:moonshotai/Kimi-K2.6 | [79%](https://github.com/langchain-ai/deepagents/actions/runs/25475600906) | [92%](https://github.com/langchain-ai/deepagents/actions/runs/25475600906) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25475600906)** | [84%](https://github.com/langchain-ai/deepagents/actions/runs/25475600906) | — | [43%](https://github.com/langchain-ai/deepagents/actions/runs/25475600906) | [60%](https://github.com/langchain-ai/deepagents/actions/runs/25475600906) |
| baseten:zai-org/GLM-5 | [77%](https://github.com/langchain-ai/deepagents/actions/runs/25403850424) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25403850424)** | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25403850424)** | [89%](https://github.com/langchain-ai/deepagents/actions/runs/25403850424) | [44%](https://github.com/langchain-ai/deepagents/actions/runs/23872647281) | [24%](https://github.com/langchain-ai/deepagents/actions/runs/25403850424) | [60%](https://github.com/langchain-ai/deepagents/actions/runs/25403850424) |
| fireworks:accounts/fireworks/models/glm-5p1 | [81%](https://github.com/langchain-ai/deepagents/actions/runs/25461031650) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25461031650)** | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25461031650)** | [87%](https://github.com/langchain-ai/deepagents/actions/runs/25461031650) | — | [33%](https://github.com/langchain-ai/deepagents/actions/runs/25461031650) | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25461031650) |
| fireworks:accounts/fireworks/models/minimax-m2p7 | [79%](https://github.com/langchain-ai/deepagents/actions/runs/25403894412) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25403894412)** | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25403894412)** | [85%](https://github.com/langchain-ai/deepagents/actions/runs/25403894412) | — | [43%](https://github.com/langchain-ai/deepagents/actions/runs/25403894412) | [60%](https://github.com/langchain-ai/deepagents/actions/runs/25403894412) |
| ollama:minimax-m2.7:cloud | [73%](https://github.com/langchain-ai/deepagents/actions/runs/24106499785) | [92%](https://github.com/langchain-ai/deepagents/actions/runs/24106499785) | [90%](https://github.com/langchain-ai/deepagents/actions/runs/24106499785) | [82%](https://github.com/langchain-ai/deepagents/actions/runs/24106499785) | [38%](https://github.com/langchain-ai/deepagents/actions/runs/23872647281) | [29%](https://github.com/langchain-ai/deepagents/actions/runs/24106499785) | [60%](https://github.com/langchain-ai/deepagents/actions/runs/24106499785) |
| openrouter:deepseek/deepseek-v4-flash | [81%](https://github.com/langchain-ai/deepagents/actions/runs/25677815395) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25677815395)** | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25677815395) | **[90%](https://github.com/langchain-ai/deepagents/actions/runs/25677815395)** | — | [33%](https://github.com/langchain-ai/deepagents/actions/runs/25677815395) | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25677815395) |
| openrouter:minimax/minimax-m2.7 | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | [92%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535)** | [89%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | — | [43%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) | [60%](https://github.com/langchain-ai/deepagents/actions/runs/25455998535) |
| openrouter:z-ai/glm-5.1 | **[89%](https://github.com/langchain-ai/deepagents/actions/runs/25387853856)** | [92%](https://github.com/langchain-ai/deepagents/actions/runs/25234719085) | **[100%](https://github.com/langchain-ai/deepagents/actions/runs/25234686782)** | [89%](https://github.com/langchain-ai/deepagents/actions/runs/25387853856) | — | [33%](https://github.com/langchain-ai/deepagents/actions/runs/25225620506) | [80%](https://github.com/langchain-ai/deepagents/actions/runs/25235579950) |

有关更多信息，请参阅 [评估运行](https://github.com/langchain-ai/deepagents/actions/workflows/evals.yml)。

## 配置模型参数

:::python
将模型字符串传递给 @\[`create_deep_agent`]，格式为 `provider:model`，或传递配置好的模型实例以进行完全控制。在底层，模型字符串通过 @\[`init_chat_model`] 进行解析。
:::

:::js
将模型字符串传递给 @\[`createDeepAgent`]，格式为 `provider:model`，或传递配置好的模型实例以进行完全控制。在底层，模型字符串通过 @\[`init_chat_model`] 进行解析。
:::

要配置模型特定参数，请使用 @\[`init_chat_model`] 或直接实例化提供者模型类：

:::python

```python init_chat_model theme={null}
from langchain.chat_models import init_chat_model
from deepagents import create_deep_agent

model = init_chat_model(
    model="google_genai:gemini-3.6-flash",
    thinking_level="medium",  # [!code highlight]
)
agent = create_deep_agent(model=model)
```

```python Provider package theme={null}
from langchain_google_genai import ChatGoogleGenerativeAI
from deepagents import create_deep_agent

model = ChatGoogleGenerativeAI(
    model="gemini-3.1-pro-preview",
    thinking_level="medium",  # [!code highlight]
)
agent = create_deep_agent(model=model)
```

:::

:::js

```ts initChatModel theme={null}
import { initChatModel } from "langchain/chat_models/universal";
import { createDeepAgent } from "deepagents";

const model = await initChatModel("google:gemini-3.6-flash", {
  reasoningEffort: "medium", // [!code highlight]
});
const agent = createDeepAgent({ model });
```

```ts Provider package theme={null}
import { ChatGoogle } from "@langchain/google";
import { createDeepAgent } from "deepagents";

const model = new ChatGoogle({
  model: "gemini-3.1-pro-preview",
  reasoningEffort: "medium", // [!code highlight]
});
const agent = createDeepAgent({ model });
```

:::

> [!NOTE]
>
> 可用参数因提供者而异。有关提供者特定的配置选项，请参阅 [对话模型集成](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat.md) 页面。

### 提供者配置文件

[`ProviderProfile`](https://langchain-docs-zh.mintlify.site/langchain/oss/deepagents/profiles#提供者配置文件) 打包在创建 Deep Agents 时提供 `provider:model` 字符串时应用的初始化参数。当您通过 @\[`init_chat_model`] 传递预配置模型时，它不适用。

您可以注册在两个级别，并且两者可以共存：

* **提供者级别**：像 `"openai"` 这样的简单提供者键适用于来自 `openai` 提供者的所有模型。
* **模型级别**：像 `provider:model` 这样的键，如 `"openai:gpt-5.4"`，仅适用于特定模型，并覆盖任何匹配的提供者级配置文件。

:::python

```python theme={null}
from deepagents import ProviderProfile, register_provider_profile

# Provider-wide default: every openai model gets temperature=0.
register_provider_profile(
    "openai",
    ProviderProfile(init_kwargs={"temperature": 0}),
)

# Model-level override: gpt-5.5 additionally gets a specific reasoning effort.
# Inherits temperature=0 from the provider-level profile above.
register_provider_profile(
    "openai:gpt-5.5",
    ProviderProfile(init_kwargs={"reasoning_effort": "medium"}),
)
```

:::

有关完整字段列表、合并语义和插件打包，请参阅 [配置文件](https://langchain-docs-zh.mintlify.site/langchain/oss/deepagents/profiles.md)。

> [!TIP]
>
> 要塑造模型构建后 *智能体* 的行为，请使用 [harness 配置文件](https://langchain-docs-zh.mintlify.site/langchain/oss/deepagents/profiles.md#链配置)。

### OpenAI 和响应 API

当您将 `openai:...` 字符串作为模型传递时，Deep Agents 使用内置的 OpenAI [提供者配置文件](https://langchain-docs-zh.mintlify.site/langchain/oss/deepagents/profiles.md#提供者配置文件) 默认启用 [响应 API](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat/openai.md#响应-api)。该路径支持 OpenAI 会话状态和相关功能；有关当前 API 选项，请参阅 [OpenAI 提供者](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/providers/openai.md) 和 [对话模型](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat/openai.md) 文档。

> [!NOTE]
>
> 内置的 OpenAI 提供者配置文件仅适用于模型字符串。要设置 kwargs，如 `use_responses_api`、`store` 或 `include`，请传递配置好的模型实例，或在 Python 中，通过 [提供者配置文件](https://langchain-docs-zh.mintlify.site/langchain/oss/deepagents/profiles.md#提供者配置文件) `init_kwargs` 层叠它们。使用 @\[`init_chat_model`]（Python）或 `initChatModel` / `ChatOpenAI`（TypeScript）构建实例。

:::python
要使用 [聊天补全](https://platform.openai.com/docs/guides/responses-vs-chat-completions) 而不是响应 API，请传递预初始化的模型，使用 `use_responses_api=False`：

```python theme={null}
from langchain.chat_models import init_chat_model
from deepagents import create_deep_agent

model = init_chat_model("openai:gpt-5.5", use_responses_api=False)
agent = create_deep_agent(model=model)
```

要保持响应 API 但禁用数据保留（`store=False`），同时仍然接收加密的推理输出，请设置 `include`，以便推理作为加密内容返回：

```python theme={null}
from langchain.chat_models import init_chat_model
from deepagents import create_deep_agent

model = init_chat_model(
    "openai:gpt-5.5",
    use_responses_api=True,
    store=False,
    include=["reasoning.encrypted_content"],
)
agent = create_deep_agent(model=model)
```

:::

:::js
使用 [OpenAI 聊天集成](https://langchain-docs-zh.mintlify.site/langchain/oss/python/integrations/chat/openai.md#响应-api) 来选择响应 API 与聊天补全（`useResponsesApi`、模型 kwargs 以及您的版本公开的任何存储或输出选项）。将生成的模型实例传递给 `createDeepAgent({ model })`，以保留这些设置。
:::

## 在运行时选择模型

如果您的应用程序允许用户选择模型（例如在 UI 中使用下拉菜单），请使用 [中间件](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/middleware/overview.md) 在运行时交换模型，而无需重新构建智能体。

:::python

通过 [运行时上下文](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models.md#动态模型选择) 传递用户的模型选择，然后使用 `wrap_model_call` 中间件，通过 @\[`@wrap_model_call`] 装饰器在每个调用中覆盖模型：

```python theme={null}
from dataclasses import dataclass
from typing import Callable

from langchain.agents.middleware import ModelRequest, ModelResponse, wrap_model_call
from langchain.chat_models import init_chat_model
from deepagents import create_deep_agent


@dataclass
class Context:
    model: str


@wrap_model_call
def configurable_model(
    request: ModelRequest,
    handler: Callable[[ModelRequest], ModelResponse],
) -> ModelResponse:
    model_name = request.runtime.context.model
    model = init_chat_model(model_name)
    return handler(request.override(model=model))


agent = create_deep_agent(
    model="google_genai:gemini-3.6-flash",
    middleware=[configurable_model],
    context_schema=Context,
)

# Invoke with the user's model selection
result = agent.invoke(
    {"messages": [{"role": "user", "content": "Hello!"}]},
    context=Context(model="openai:gpt-5.5"),
)
```

> [card] [View example trace](https://smith.langchain.com/public/00753a64-5eb8-4c9e-aac1-4116a90d2ac9/r)
>
> 为此示例打开一个公开的 LangSmith 运行。

:::

:::js

```ts theme={null}
import { createMiddleware, initChatModel } from "langchain";
import { createDeepAgent } from "deepagents";
import * as z from "zod";

const contextSchema = z.object({
  model: z.string(),
});

const configurableModel = createMiddleware({
  name: "ConfigurableModel",
  wrapModelCall: async (request, handler) => {
    const modelName = request.runtime.context.model;
    const model = await initChatModel(modelName);
    return handler({ ...request, model });
  },
});

const agent = await createDeepAgent({
  model: "google:gemini-3.6-flash",
  middleware: [configurableModel],
  contextSchema,
});

// Invoke with the user's model selection
const result = await agent.invoke(
  { messages: [{ role: "user", content: "Hello!" }] },
  { context: { model: "openai:gpt-5.5" } },
);
```

> [card] [View example trace](https://smith.langchain.com/public/4440a203-58dc-4f45-8a81-4e1733e91016/r)
>
> 为此示例打开一个公开的 LangSmith 运行。

:::

> [!TIP]
>
> 对于更动态的模型模式（例如基于对话复杂性或成本优化的路由），请参阅 LangChain 智能体指南中的 [动态模型](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models.md#动态模型选择)。

## 了解更多

* [LangChain 中的模型](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models.md)：包含工具调用、结构化输出和多模态的对话模型特性

***

> 官方原文：[src/oss/deepagents/models.mdx](https://github.com/langchain-ai/docs/blob/main/src/oss/deepagents/models.mdx) · 非官方翻译，译文由 AI 生成，以英文原文为准。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.