Skip to content
Go to Dashboard

5 分钟上手

5 分钟。注册账号、装 SDK、起一个 task、看到事件流回来。

Step 0 —— 拿到 API key(30 秒)

  1. console.web-agent.asix.inc 注册
  2. Settings → API Keys → Create
  3. 复制 wa_…。**只显示一次。**丢了只能撤销重建
bash
export WEBAGENT_API_KEY=wa_xxxxxxxxxxxxxxxxxxxxxxxx
export WEBAGENT_PROJECT_ID=proj_xxxxxxxxxxxxxxxxxxxxxxxx

Project ID

所有 project-scoped 路径都以 project 为隔离单位:/v1/projects/{pid}/…(DoAnything / WebSearch / Track)。在 Console URL 里Project Switcher → 你的 project就能找到。Standalone 端点(DeepResearch)的 project 由 Bearer token 解析。

Step 1 —— 装 SDK(30 秒)

bash
pip install web-agent-sdk
bash
npm install @web-agent/sdk
bash
# 不用装

Step 2 —— 跑一个 task(90 秒)

Client 起一个 DoAnything session,订阅事件流到终态。

python
import asyncio
from web_agent.v1 import Client
from web_agent.v1.types import CreateSessionRequest

async def main():
    async with Client(
        api_key="wa_demo_xxxxxxxxxxxxxxxx",
        project_id="proj_demo_0001",
    ) as client:
        session = await client.sessions.create(CreateSessionRequest(
            instructions="搜 Hacker News 今天 Top 5 的故事,列成 list 返回。",
        ))
        task = session.tasks[0]
        async for event in client.events.stream(session.id, task.id):
            print(event.type, event.data)
            if event.type == "task.completed":
                break

asyncio.run(main())
typescript
import { Client } from "@web-agent/sdk";

const client = new Client({
  apiKey: "wa_demo_xxxxxxxxxxxxxxxx",
  projectId: "proj_demo_0001",
});

const session = await client.sessions.create({
  instructions: "搜 Hacker News 今天 Top 5 的故事,列成 list 返回。",
});
const task = session.tasks[0]!;
for await (const event of client.events.stream(session.id, task.id)) {
  console.log(event.type, event.data);
  if (event.type === "task.completed") break;
}
bash
curl https://api.web-agent.asix.inc/v1/projects/proj_demo_0001/do_anything/sessions \
  -H "Authorization: Bearer wa_demo_xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "instructions": "搜 Hacker News 今天 Top 5 的故事,列成 list 返回。"
  }'

同样的代码 Console 也能给你

Console 的 Get Code 对话框输出的就是这段——带你的真实 API key 和当前表单值。打开 console.web-agent.asix.inc/new,填表,点 Get Code,就省掉了打字。

Step 3 —— 知道产物形态时换走定型 API(60 秒)

DoAnything 是开放型(产物形态不定)。如果你知道自己要的是研究报告 / 解题 / 搜索结果,走对应的定型 API 拿质量契约:

python
async with Client(api_key="wa_...", project_id="proj_demo") as client:
    task = await client.deep_research.run(
        topic="2026 年开源向量数据库格局",
        depth="deep",
    )
    print(task["task_id"])
python
async with Client(api_key="wa_...", project_id="proj_demo") as client:
    # wait=true 默认,同步阻塞 ≤30s
    result = await client.web_search.run(
        queries=["best Python ORM 2026"],
    )
    for hit in result["results"]["results"]:
        print(hit["title"], hit["url"])
python
async with Client(api_key="wa_...", project_id="proj_demo") as client:
    mon = await client.track.create(
        intent="苹果股价跌破 $200 时通知我",
        schedule={"kind": "interval", "every_seconds": 3600},
        notify_channel={"kind": "callback_url", "url": "https://hooks.example.com/track"},
    )
    print(mon["id"])

定型 API 的端点 / 字段 / 错误信封都跟 DoAnything 走同一份契约——见 Python SDK / TypeScript SDK

Step 4 —— 在 Console 看一眼(30 秒)

打开 https://console.web-agent.asix.inc/sessions/<session.id>(用 step 2 打印的 id)。你会看到刚才那个 task 的 chat + Live Preview iframe——和 SSE 流里的内容一样,可视化呈现。

接下来呢

排错

现象原因
401 unauthorizedkey 错 / 过期 / 撤销Settings → API Keys 重建
402 insufficient_credits免费额度耗尽Settings → Billing → Add credits
SSE 流卡 60s+网络断 / proxy 缓冲Last-Event-ID 重连,详见 Events & SSE
429 rate_limit_exceeded短时间 burst退避重试;Dev plan 默认 5–10 并发