用 Mistral Agents API 构建 AI 智能体
Build AI agents with the Mistral Agents API
Mistral 公布 Agents API,让开发者结合代码执行、网页搜索、图像生成、文档库和 MCP 工具,以及持久记忆与智能体编排,构建能执行动作并保持上下文的 AI 智能体。
官方把代码执行、网页搜索、图像生成和文档库接到有状态对话与智能体交接上,读者可以据此比较它和普通对话接口的实际分工。

今天,我们宣布推出全新的 Agents API,这是让 AI 更强大、更实用并成为主动问题解决者的重要一步。
传统语言模型擅长生成文本,但在执行操作或维持上下文方面能力有限。我们全新的 Agents API 通过将 Mistral 强大的语言模型与以下能力相结合,解决了这些局限:
用于代码执行、网页搜索、图像生成和 MCP 工具的内置连接器
跨对话的持久记忆
智能体编排能力
Agents API 通过提供专门框架来简化智能体用例的实现,从而补充我们的 Chat Completion API。它是企业级智能体平台的骨干。
通过为 AI 智能体提供可靠框架,以处理复杂任务、维持上下文并协调多项操作,Agents API 使企业能够以更实用、更有影响力的方式使用 AI。
Mistral 智能体实战。
探索 Mistral 的 Agents API 在各个领域的多样化应用:
集成 Github 的编程助手。
一个使用 Mistral 的 Agents API 构建的智能体工作流:智能体与 Github 交互,并监督由 DevStral 驱动的开发者智能体编写代码。该智能体被授予对 Github 的完全权限,展示了自动化的软件开发任务管理。
Linear 工单助手。
一款由我们的 Agents API 驱动的智能任务协调助手,采用多服务器 MCP 架构,将通话转录转化为 PRD,再转化为可执行的 Linear 议题,并跟踪项目交付成果。
金融分析师。
一个使用我们的 Agents API 构建的财务顾问智能体,可编排多个 MCP 服务器,以获取财务指标、汇总洞察并安全地归档结果。
旅行助手。
一款强大的 AI 旅行助手,帮助用户规划行程、预订住宿并管理旅行需求。
营养助手。
一款由 AI 驱动的饮食伴侣,旨在帮助用户设定目标、记录餐食、获取个性化食物建议、跟踪每日成果,并发现符合其营养目标的用餐选择。
使用内置连接器和 MCP 工具创建智能体。
每个智能体都可以配备强大的内置连接器(即已部署、可供智能体按需调用的工具)以及 MCP 工具:
代码执行
The Agents API can use the code execution connector, empowering developers to create agents that execute Python code in a secure sandboxed environment. This enables agents to tackle a wide range of tasks, including mathematical calculations and analysis, data visualization and plotting, and scientific computing.图像生成
The image generation connector tool, powered by Black Forest Lab FLUX1.1 [pro] Ultra, enables agents to create images for diverse applications. This feature can be leveraged for various use cases such as generating visual aids for educational content, creating custom graphics for marketing materials, or even producing artistic images.文档库
Document Library is a built-in connector tool that enables agents to access documents from Mistral Cloud. It powers the integrated RAG functionality, strengthening agents’ knowledge by leveraging the content of user-uploaded documents.网页搜索
The Agents API offers web search as a connector, enabling developers to combine Mistral models with diverse, up-to-date information from web search, reputable news, and other sources. This integration facilitates the delivery of up-to-date, informed, evidence-supported responses.
Agents with web search capabilities show a significant improvement in performance. In the SimpleQA benchmark, Mistral Large and Mistral Medium with web search achieve scores of 75% and 82.32%, respectively, compared to 23% and 22.08% without web search (see figure below).SimpleQA 准确率(越高越好)
MCP 工具
The Agents API SDK can also leverage tools built on the Model Context Protocol (MCP)—an open, standardized protocol that enables seamless integration between agents and external systems. MCP tools provide a flexible and extensible interface for agents to access real-world context, including APIs, databases, user data, documents, and other dynamic resources. Check out the Github, Financial Analyst, and Linear MCP demos to learn how to use MCP tools with Mistral Agents in action.
通过有状态对话实现的记忆与上下文。
Agents API 通过灵活的有状态对话系统提供强大的对话管理。每次对话都会保留其上下文,使交互能够长期保持顺畅连贯。
对话管理
There are two ways to start a conversation:
Each conversation maintains a structured history through conversation entries, ensuring that the context is preserved across interactions.借助智能体:使用特定的 agent_id 创建对话,以利用其专业能力。
直接访问:通过直接指定模型和补全参数来开始对话,从而快速访问内置连接器。
有状态交互与对话分支
Developers are no longer required to monitor conversion history; they have the ability to view past conversations. They can always continue any conversation or initiate new conversation paths from any point.流式输出
The API also supports streaming outputs, both when starting a conversation and continuing a previous one. This feature allows for real-time updates and interactions.
智能体编排。
我们的 Agents API 的真正强大之处在于,它能够编排多个智能体来解决复杂问题。通过动态编排,可以根据需要在对话中添加或移除智能体——每个智能体都贡献其独特能力,以处理问题的不同部分。
创建智能体工作流
To build a workflow with handoffs, start by creating all necessary agents. You can create as many agents as needed, each with specific tools and models, to form a tailored workflow.智能体交接
Once agents are created, define which agents can hand off tasks to others. For example, a finance agent might delegate tasks to a web search agent or a calculator agent based on the conversation's needs.
Handoffs enable a seamless chain of actions. A single request can trigger tasks across multiple agents, each handling specific parts of the request. This collaborative approach allows for efficient and effective problem-solving, unlocking powerful possibilities for real-world applications.
开始使用。
要开始使用,请查看我们的 文档,创建你的第一个智能体,然后开始构建!
来源:Mistral AI · mistral.ai