快速开始
在 Astreus 文档中了解 快速开始,获取用于构建智能体系统的设置指导、API 模式和实用示例。 了解构建可靠的 Astreus 智能体系统所需的设置模式、API 和实用示例。
在 5 分钟内创建你的第一个 Astreus 智能体项目。
安装方式
使用 npx(推荐)
npx create-astreus-agent my-agent使用 npm create
npm create astreus-agent my-agent使用 pnpm
pnpm create astreus-agent my-agent交互式设置
1. 项目名称
? What is your project name? my-agent输入你的项目名称,系统会创建一个新目录。只允许使用字母、数字、短横线和下划线。
2. 功能选择
? Which features do you want to include?
◉ Memory - Persistent agent memory with vector search
◉ Knowledge (RAG) - Document ingestion and retrieval
◯ Graph Workflows - DAG-based task orchestration
◯ Sub-Agents - Multi-agent coordination
◯ Custom Plugins - Extensible tool system
◯ MCP Integration - Model Context Protocol support使用方向键和空格键选择功能。所有功能都是可选的。
3. LLM 提供商
? Which LLM provider do you want to use?
● OpenAI - GPT-4, GPT-3.5
○ Anthropic - Claude
○ Google - Gemini
○ Ollama - Local models
○ Multiple providers - Configure later选择你偏好的提供商,或者选择“Multiple providers”稍后配置。
4. TypeScript
? Use TypeScript? Yes推荐使用 TypeScript 以获得更好的开发体验。
安装完成后
项目创建完成后:
# 进入项目目录
cd my-agent
# 安装依赖
npm install
# 复制环境变量模板
cp .env.example .env
# 编辑 .env 并填入你的 API 密钥
nano .env # 或使用你偏好的编辑器
# 启动智能体
npm run dev示例:第一次对话
启动后,你的智能体已经准备就绪:
import { Agent } from '@astreus-ai/astreus';
import 'dotenv/config';
const agent = await Agent.create({
name: 'my-agent',
model: 'gpt-4o',
memory: true,
});
// Have a conversation
const response = await agent.ask("Hello! What can you help me with?");
console.log(response);生成的代码
CLI 会生成一个完整的 src/index.ts:
import { Agent } from '@astreus-ai/astreus';
import 'dotenv/config';
async function main() {
console.log('Starting Astreus Agent...\n');
const agent = await Agent.create({
name: 'my-agent',
model: 'gpt-4o',
systemPrompt: 'You are a helpful AI assistant powered by Astreus.',
memory: true,
});
// Interactive loop
const readline = await import('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
console.log('Agent ready! Type your message (or "exit" to quit):\n');
const prompt = () => {
rl.question('You: ', async (input) => {
if (input.toLowerCase() === 'exit') {
console.log('\nGoodbye!');
rl.close();
process.exit(0);
}
try {
const response = await agent.ask(input);
console.log(`\nAgent: ${response}\n`);
} catch (error) {
console.error('Error:', error instanceof Error ? error.message : error);
}
prompt();
});
};
prompt();
}
main().catch(console.error);环境要求
- Node.js >= 22.0.0
- npm、yarn 或 pnpm
- LLM 提供商的 API 密钥(或使用 Ollama 运行本地模型)
后续步骤
最后更新时间:2026年7月6日
本节内容