线程HTTP API
Threads HTTP API
导读
Amp Chronicle 发布 Threads HTTP API,用户现在可以通过该 API 创建 Amp orb 线程、读取 agent 响应并发送后续消息。要使用该功能,需在 Settings → Access Tokens 创建具有 amp.api:threads:write、amp.api:threads.meta:read 和 amp.api:threads.contents:read 权限的个人访问令牌;用于组织或团队级自动化时,建议改用服务账号。
正在把原文翻译成中文,长文需要一两分钟;先显示原文。
You can now create Amp orb threads, read agent responses, and post follow-up messages through the HTTP API.
This makes it easy for any automated system to delegate work to Amp:
- Investigate alerts. An error tracker or paging webhook starts a thread for each critical alert.
- Fix CI failures. When CI fails on
main, a thread finds the cause and opens a fix PR. - Triage on a schedule. Every morning, a job sends the past day's top errors to Amp.
- Start threads from bots and internal tools. A Slack bot, a support workflow, or an issue-report queue starts a thread, then reads the result or sends a follow-up.
To try it, create a personal access token in Settings → Access Tokens with these scopes:
amp.api:threads:writeamp.api:threads.meta:readamp.api:threads.contents:read
If you're testing this in the terminal, set AMP_TOKEN to this value.
Then, start a new orb thread:
curl https://ampcode.com/api/v2/threads \
-H "Authorization: Bearer $AMP_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"project": "my-workspace/my-project",
"title": "Fix CI on main",
"labels": ["ci-failure"],
"message": "Fix this CI failure: https://github.com/org/repo/actions/runs/1"
}'
Read the agent's response:
curl "https://ampcode.com/api/v2/threads/$THREAD_ID/messages?limit=100" \
-H "Authorization: Bearer $AMP_TOKEN"
And send a follow-up message:
curl https://ampcode.com/api/v2/threads/$THREAD_ID/messages \
-H "Authorization: Bearer $AMP_TOKEN" \
-H "Content-Type: application/json" \
-d '{"message": "Add a regression test for this failure."}'
For organization or team-level automations, we recommend using a service account. Create the service account's access token in Workspace Settings → Service Accounts. Remember to connect the service account to GitHub or your code host, so it can clone repositories.

See the Threads API docs for full details.
出处
- S 官方Amp Chronicle · 网站阅读原文 ↗
Threads HTTP API