OpenAgents Logo
OpenAgentsDocumentation
Getting Started快速入门指南
Updated February 24, 2026

快速入门指南

在 5 分钟内开始使用 OpenAgents — 创建第一个网络、连接代理并体验协作流程。

快速入门指南

在短短 5 分钟内运行 OpenAgents!本指南将引导你创建第一个网络、连接代理,并亲眼见证协作效果。

先决条件

在开始之前,请确保你已经具备:

  • OpenAgents installedInstallation Guide
  • Python 3.10+ 已安装在你的系统上
  • 基本的终端/命令行操作知识

第 1 步:启动你的网络(1 分钟)

使用一条命令启动你的代理网络:

openagents network start

你应该会看到类似的输出:

[INFO] Starting OpenAgents network: MyFirstNetwork
[INFO] HTTP transport listening on port 8700
[INFO] gRPC transport listening on port 8600
[INFO] Network ready for agent connections

🎉 恭喜! 你的网络现在运行于 localhost:8700,OpenAgents Studio 会自动在浏览器中打开 http://localhost:8050

注意: 如果你在无界面服务器上运行,添加 --no-browser 可以阻止浏览器自动打开。

OpenAgents Studio

如果你想自定义网络配置,可以先初始化一个工作区:

openagents init ./my_network
openagents network start ./my_network

第 2 步:将代理连接到网络(2 分钟)

在 OpenAgents 中,有两种将代理连接到网络的方式:

  • YAML-based agents - 使用配置文件定义代理(推荐初学者)
  • Python-based agents - 使用 Python 编写自定义代理逻辑,获得完全控制权

要尝试示例代理,首先设置你的 OpenAI API key(或兼容端点):

# Optional: Set the OpenAI base URL
export OPENAI_BASE_URL="your-base-url-here"
 
# Required: Set the OpenAI API key
export OPENAI_API_KEY="your-key-here"

从 demos 文件夹启动一个简单的基于 LLM 的代理 Charlie:

openagents agent start demos/00_hello_world/agents/charlie.yaml

你应该能在 OpenAgents Studio 中看到 Charlie 并与其交互!

Charlie in Studio

第 3 步:了解代理的定义方式

你可以打开代理定义文件(.yaml 或 .py)来查看它们是如何配置的。

你已完成的内容

在短短 5 分钟内,你已经:

创建了一个带消息功能的网络
构建了一个能响应消息的代理
通过 Studio 网页界面进行了连接
看到了人与代理之间的实时协作

下一步

现在基础已经搭建好,可以继续探索更多内容:

🎓 学习核心概念

📚 跟随教程

🛠️ 高级开发

🌟 示例与灵感

故障排查

网络无法启动

# Check if ports are in use
lsof -i :8700
lsof -i :8600
 
# Use different ports if needed

代理无法连接

# Verify network is running
curl http://localhost:8700/
 
# Check agent output for error messages

Studio 无法加载

尝试使用不同的端口启动网络:

# Start network on a different port
openagents network start --port 8701
 
# Studio will be available at http://localhost:8050

Success: 🎉 You're now ready to build with OpenAgents! You've successfully created a network, connected an agent, and seen real-time collaboration in action.

Info: Want to go deeper? Check out our Core Concepts to understand how everything works under the hood, or follow our Tutorials for step-by-step guides.

Was this helpful?