Skip to content

💡 什麼是 API?— 為什麼你需要它?

把你的 AI agents 想像成需要思考才能行動的員工。

每次 agent 分析情況、撰寫報告或做出決定時,它都需要呼叫 AI model 來進行思考。API 是進行該呼叫的通道 — 也是驅動它的燃料。

Chat AI vs API — 兩個不同的東西:

Chat AI (Claude / Gemini / ChatGPT)API
是什麼你的私人禮賓員你的 agents 思考引擎
誰使用它你,直接使用你的 agents,自動使用
成本模式訂閱制(固定費率)按使用次數計費(input + output tokens)
建議付費方案 — 更好的推理能力從 $5 額度開始

為什麼同時運行兩個?(混合設置)

API 計費基於 input + output tokens — 發送給 agent 的每個詞以及它回應的每個詞都需要花費少量費用。

這意味著你如何指示 agents 很重要。

使用你的 Chat AI(Claude、Gemini、ChatGPT — 建議使用付費方案以獲得更好的推理能力)來:

  • 在發送給 agents 之前起草清晰、簡潔的指示
  • 在將長文檔傳遞給 agents 之前進行摘要
  • 預先結構化任務,使 agents 不會浪費 tokens 去理解你的需求

一份結構良好的 200-token 指示成本遠低於模糊的 2,000-token 來回對話。 你的 Chat AI 是策略家。你的 agents 是執行者。 這個組合能在保持輸出品質高的同時降低 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 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 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 ~/.openclaw/ 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%\.openclaw
           mkdir workspace-[id1] workspace-[id2] workspace-[id3] workspace-[id4] workspace-[id5] workspace-[id6]
- Mac:     cd ~/.openclaw
           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 7
# 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 7.
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 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.