💡 什么是 API?— 以及为什么你需要它?
把你的 AI 代理想象成需要在行动前进行思考的员工。
每当代理分析情况、撰写报告或做出决定时,它需要调用 AI 模型来完成思考。API 是进行该调用的渠道 — 也是为其提供动力的燃料。
Chat AI 与 API — 两种不同的东西:
| Chat AI (Claude / Gemini / ChatGPT) | API | |
|---|---|---|
| 它是什么 | 你的私人礼宾服务 | 你的代理的思维引擎 |
| 谁使用它 | 你,直接使用 | 你的代理,自动使用 |
| 成本模型 | 订阅(固定费率) | 按使用付费(input + output tokens) |
| 推荐方案 | 付费计划 — 更好的推理能力 | 从 $5 信用额开始 |
为什么同时运行两者?(混合设置)
API 计费基于 input + output tokens — 发送给代理的每个单词和它响应的每个单词都需要支付少量费用。
这意味着你如何指示代理很重要。
使用你的 Chat AI(Claude、Gemini、ChatGPT — 推荐使用付费计划以获得更好的推理能力)来:
- 在发送给代理前起草清晰、简洁的指令
- 在将长文档传递给代理前总结它们
- 预先结构化任务,这样代理就不会浪费 tokens 来弄清楚你想要什么
一个结构良好的 200-token 指令的成本远低于一个模糊的 2,000-token 的来回对话。 你的 Chat AI 是战略家。你的代理是执行者。 这种组合保持 API 成本低廉,同时保持输出质量高。
开始之前 — API 费用说明
运行 BALIA OS 的 AI 代理需要 AI API 密钥,这与 $48 指南费用是分开的。
所需内容:
- 一个 Anthropic 账户,至少 $5 的预付积分
- 本指南中的所有代理均使用 Claude Sonnet 4.6
为什么 $5 足以开始: Claude Sonnet 4.6 的价格为每百万输入 token $3,每百万输出 token $15。典型代理会话使用几千个 token,$5 可让您进行数十次学习和实验。
Anthropic API 没有免费套餐。 需要信用卡。 充值地址:console.anthropic.com → Billing → Add credits(最低 $5)
这是运行 BALIA OS 所需的唯一外部费用。 做个比较:雇用一名人工助理每月需要 $2,000–$5,000。您的 AI 团队只需 $5 的 API 积分即可启动。相同的工作,极低的成本。
您将安装的内容
完成本节后,您将准备好以下四项内容:
- VS Code — 用于编辑智能体文件和运行命令的 workspace
- Node.js — 运行 OpenClaw 的必要环境
- OpenClaw — 驱动 BALIA OS 的 AI 智能体框架
- Anthropic API 密钥 — 智能体用于思考的 AI 引擎
本节的使用方式: 复制下方的提示词,粘贴到 Claude、ChatGPT 或 Gemini 中。AI 将全程引导您完成安装——询问您的操作系统、逐步带您完成每个步骤,并帮助您解决任何问题。如果在任何环节遇到困难,只需向 AI 描述问题,它会帮您解决。
▶ 将此粘贴到您的 AI 中以开始
You are helping me install and set up BALIA OS — a multi-agent AI
operating system built on OpenClaw.
Your job is to guide me through the installation step by step.
Ask me one question at a time. Wait for my answer before moving on.
If I hit an error, help me fix it before continuing.
Here is everything we need to install and set up, in order:
STEP 1 — Check my operating system
Ask me: "Are you on Windows or Mac?"
Then give me the correct instructions for my OS throughout all steps.
STEP 2 — Install VS Code
Guide me to install VS Code from code.visualstudio.com
- Windows: download and run the installer. Make sure "Add to PATH" is checked.
- Mac: download, unzip, drag to Applications, then run the shell command
to add "code" to PATH: Cmd+Shift+P → "Shell Command: Install 'code' command in PATH"
After install, ask me to open a terminal in VS Code and run:
code --version
Ask me what it shows. If there's an error, help me fix it.
STEP 3 — Create the balia-os folder
Guide me to create the main BALIA OS folder using the VS Code terminal.
- Windows: mkdir C:\Users\%USERNAME%\balia-os
code C:\Users\%USERNAME%\balia-os
- Mac: mkdir ~/balia-os
code ~/balia-os
Tell me: "This is where everything will live.
Keep this path handy — you'll use it throughout the guide."
Confirm the folder opened in VS Code before moving on.
STEP 4 — Install Node.js
Guide me to install Node.js 22 or higher from nodejs.org (LTS version).
After install, ask me to run: node --version
Ask me what it shows.
- If v22 or higher: great, move on.
- If lower than v22: guide me to upgrade using nvm (Mac/Linux)
or nvm-windows (Windows).
- If error: help me troubleshoot.
STEP 5 — Install OpenClaw
Guide me to run in the VS Code terminal:
npm install -g openclaw
Then verify:
openclaw --version
Common errors to handle:
- EACCES on Mac: guide through npm global prefix fix
- "openclaw not found": ask me to close and reopen terminal, try again
STEP 6 — Get an Anthropic API key
Explain this first:
"BALIA OS uses Claude (Anthropic) as the default AI engine for your agents.
For now we set up Claude only. Other AI engines can be added later depending
on what you want to build:
- When building your own cassette (Section 6), you'll choose the best AI
for that cassette — for example, Gemini for YouTube since it can analyze
video directly, or GPT-4o for sales copy.
- After the BALIA Skill Market opens, you can also install cassettes built
by other users, each with their own recommended AI engine.
There is no cassette included by default. You'll build the one that fits
your business in Section 6."
Then guide me to:
1. Go to console.anthropic.com
2. Sign up or log in
3. Go to API Keys → Create Key
4. Name it "balia-os"
5. Copy the key (starts with sk-ant-)
Tell me: "Save this somewhere safe — you can only see it once."
Ask me to confirm I have the key before moving on.
Do NOT ask me to paste the key into the chat.
STEP 7 — Run OpenClaw setup
Guide me to run in the VS Code terminal:
openclaw setup
Tell me what to expect:
- It will ask for my Anthropic API key — paste it there
- It will create ~/.opengoat/ folder structure
- It will start the OpenClaw gateway
After setup, ask me to confirm I see:
"✓ Gateway running on port 18789"
Tell me to leave this terminal tab open and open a new tab for future commands.
STEP 8 — Create workspace folders for each agent
Tell me: "I'll read your Team Design Document from Section 2 to get
your agent IDs automatically. Please attach it now."
Read the attached Team Design Document.
Extract all 6 agent names/IDs (convert to lowercase, no spaces).
Show me the list:
"I found these 6 agents: [id1], [id2], [id3], [id4], [id5], [id6]
Is this correct?"
Wait for my confirmation.
Then give me the exact commands to create all 6 workspace folders at once
with the actual IDs already filled in:
- Windows: cd C:\Users\%USERNAME%\.opengoat
mkdir workspace-[id1] workspace-[id2] workspace-[id3] workspace-[id4] workspace-[id5] workspace-[id6]
- Mac: cd ~/.opengoat
mkdir workspace-[id1] workspace-[id2] workspace-[id3] workspace-[id4] workspace-[id5] workspace-[id6]
STEP 9 — Create the .env file
Guide me to create a .env file inside the balia-os folder.
In VS Code: right-click the balia-os folder in the left panel →
New File → name it .env
Then paste this template:
# BALIA OS
BALIA_TOKEN=paste-your-token-here
AGENT_ID=paste-your-main-agent-id-here
BALIA_OS_PATH=~/balia-os
# Anthropic API
ANTHROPIC_API_KEY=sk-ant-paste-your-key-here
# Agent model
CLAUDE_MODEL=claude-sonnet-4-6
# Discord Webhooks — fill these in during Section 4
# Example: DISCORD_WEBHOOK_MAYA=https://discord.com/api/webhooks/123456789/xxxxxxxxxxxx
DISCORD_WEBHOOK_[AGENT1NAME]=
DISCORD_WEBHOOK_[AGENT2NAME]=
DISCORD_WEBHOOK_[AGENT3NAME]=
DISCORD_WEBHOOK_[AGENT4NAME]=
DISCORD_WEBHOOK_[AGENT5NAME]=
DISCORD_WEBHOOK_SECURITY=
Fill in BALIA_TOKEN:
"Check the email you received after purchase.
The subject line says 'Your BALIA OS Access Token'.
Copy the token (starts with BALIA-) and paste it after BALIA_TOKEN=
This is the only time you need to enter it —
the installer in Section 6 reads it automatically from this file.
Do NOT paste it into this chat."
Fill in AGENT_ID:
"This is the ID of your main agent — the one you'll talk to most.
You chose it in Section 2 (it's in your Team Design Document).
Type it in lowercase with no spaces. Example: maya, alex, ceo
This ID is used by install scripts so it must match exactly."
Fill in BALIA_OS_PATH:
"This is the folder you created in STEP 3.
- Windows: replace ~/balia-os with C:/Users/YourName/balia-os
- Mac: leave it as ~/balia-os
You'll use this path in Section 5 when launching your agents."
Tell me: "Leave these blank for now — you'll get the actual URLs in Section 4.
The URL format looks like: https://discord.com/api/webhooks/numbers/letters
Replace [AGENT1NAME] through [AGENT5NAME] with your agents' names in UPPERCASE.
DISCORD_WEBHOOK_SECURITY is always last — it's for the Security Guardian agent."
Security note — say this:
"If you're uncomfortable putting your token in a file:
You can skip BALIA_TOKEN for now and enter it manually
when prompted during Section 6 installation."
Tell me: "Never share this file. Never commit it to GitHub."
STEP 6b — Write the API key to the .env file
Guide me to:
1. Open the .env file in VS Code (it's in the balia-os folder)
2. Find the line: ANTHROPIC_API_KEY=sk-ant-paste-your-key-here
3. Replace "sk-ant-paste-your-key-here" with my actual key
4. Save the file (Ctrl+S on Windows / Cmd+S on Mac)
Confirm: "Your API key is now saved in your .env file.
Never share this file or commit it to GitHub."
Do NOT ask me to paste the key into the chat.
STEP 10 — Final check
Run through this checklist with me one item at a time:
□ code --version → shows a version number
□ node --version → shows v22 or higher
□ openclaw --version → shows a version number
□ Gateway terminal shows "✓ Gateway running"
□ balia-os folder is open in VS Code
□ .env file exists in the balia-os folder
□ BALIA_TOKEN is filled in (or noted to enter manually in Section 6)
□ AGENT_ID is filled in
□ BALIA_OS_PATH is filled in
When all boxes are checked, say:
"Installation complete. You're ready for Section 4 —
Creating Your Agent Files."
Start now. Ask me the first question.