AI Agent API 指南
复制提示词给 AI Agent 以使用 xAIcreator API
最快的方式: 在创作页打开 AI 助手面板,点击面板头部的 Agent CLI 按钮,一键复制接入指令。把它粘贴给 Claude Code、Codex、Cursor 或任意 Agent,Agent 会自己发起授权——引导你在浏览器里确认后,它才拿到属于自己的密钥,全程不经过剪贴板。所有 Agent 都读取同一份实时更新的公开文档 SKILL.md。
复制以下任意提示词发给 AI Agent(Claude、ChatGPT 等)即可帮你使用 xAIcreator API。
推荐:一个 xAIcreator 用户 Key,发布时选择 Social Set
Agent Key 的主体是 xAIcreator 用户账号,不是某个 X 账号。同一个 Key 可以操作该用户的多个 Social Set;每次创建或发布通过 socialSetId 指定目标。权限只区分 Monitor 读取、草稿读写与发布。
由用户用现有用户 Key(下方旧接口使用的 sk- Key)创建受限 Agent Key,再把返回的 xai_agent_ secret 配置到 Agent 的秘密管理器。不要把 X OAuth 凭据交给 Agent。Key 只显示一次,默认有效期 90 天;不指定 scopes 时不授予发布权限。
xaic --output json key create --name content-agent --scopes monitor:read,drafts:read,drafts:write,tweets:publish
配置 Agent Key 后:
xaic --output json whoami
xaic --output json social-set list
xaic --output json monitor signals --preset ai-agent --hours 24
xaic --output json monitor posts
xaic --output json tweet create --social-set-id SOCIAL_SET_UUID --content '先保存为草稿'
xaic --output json publish DRAFT_UUID --social-set-id SOCIAL_SET_UUID --idempotency-key campaign-post-001
xaic --output json tweet publish --social-set-id SOCIAL_SET_UUID --content '已授权发布的内容' --idempotency-key campaign-post-002
xaic --output json tweet status REQUEST_UUID
对应 API 为 /api/v1/agent/social-sets、/agent/monitor/viral、/agent/monitor/posts、/agent/drafts、/agent/publish 和 /agent/publish/:id,使用 xai-key 或 Bearer。创建 / 发布请求必须带 socialSetId;服务端检查 Set 归属,再解析并校验其 X 发布账号,不接受客户端覆盖 accountIds 或 user_uuid。
Monitor 返回当前授权窗口内最早已监听到的代表及 contentAggregation,不宣称全网首发。可读取系统榜单与自己的个人 Monitor;草稿按用户归属校验,可按 Social Set 筛选,也支持用户已有草稿。
首阶段仅支持每个 Social Set 的单个 X 账号、文本 / 文本 thread;没有 X 或多个 X 账号的 Set 会明确报错。不开放媒体、排程、其他平台、自动私信或模板修改。受限 Key 不能管理 Key 或调用旧的用户级接口;旧 sk- 接口保持兼容。
请明确授权 Agent 发布。必须传稳定的 Idempotency-Key,同一 Set 同一意图重试保持键与请求不变。遇到 PUBLISH_OUTCOME_UNKNOWN 或 PUBLISH_IN_PROGRESS_OR_UNKNOWN,先查 requestId、核对 X,不要换新幂等键自动再发。OAuth 和现有 Credits 计费留在服务端。
用户使用原用户 Key 执行 xaic key list 与 xaic key revoke KEY_UUID 管理授权。新功能需要匹配的服务端部署和迁移 0039。
1. 邮箱登录获取 API Key
复制此提示词:
你是 xAIcreator API 助手。请帮我通过邮箱登录获取 API Key。
基础 URL: https://xaicreator.com/api/v1
API 端点:
POST /api/v1/auth/login
Content-Type: application/json
请求体:
{
"email": "[email protected]",
"password": "yourpassword"
}
请询问我的邮箱和密码,然后调用 API 获取我的 API Key。响应中的 API Key 位于 response.apiKey.key 字段。
重要提示:请提醒我立即保存 API Key,因为它只显示一次。
2. Twitter OAuth 获取 API Key
复制此提示词:
你是 xAIcreator API 助手。请帮我通过 Twitter OAuth 获取 API Key。
基础 URL: https://xaicreator.com/api/v1
步骤 1 - 获取 OAuth URL:
POST /api/v1/auth/oauth/twitter/url
Content-Type: application/json
请求体:
{
"redirectUri": "http://localhost:3000/oauth-callback?provider=twitter"
}
步骤 2 - 回调(用户授权后):
POST /api/v1/auth/oauth/twitter/callback
Content-Type: application/json
请求体:
{
"code": "authorization-code-from-twitter",
"state": "state-from-step-1"
}
流程:
1. 调用步骤 1 获取 authUrl
2. 给我 authUrl 让我在浏览器中打开
3. 我授权后,Twitter 会重定向并返回 code 和 state
4. 调用步骤 2,传入 code 和 state
5. 从 response.apiKey.key 返回我的 API Key
重要提示:API Key 只显示一次,请提醒我立即保存。
3. 创建草稿
复制此提示词:
你是 xAIcreator API 助手。请帮我创建一个草稿。
基础 URL: https://xaicreator.com/api/v1
认证方式:xai-key 请求头(我会提供我的 API Key)
API 端点:
POST /api/v1/twitter/drafts
xai-key: MY_API_KEY
Content-Type: application/json
请求体:
{
"title": "我的帖子标题",
"tweets": [
{"content": "第一条推文内容"}
],
"socialSetId": "可选的-social-set-id"
}
请询问我:
1. 我的 API Key
2. 草稿标题
3. 推文内容(可以是多条推文形成 thread)
然后创建草稿,并返回 response.draft.id 中的草稿 ID
4. 发布草稿
复制此提示词:
你是 xAIcreator API 助手。请帮我发布一个草稿。
基础 URL: https://xaicreator.com/api/v1
认证方式:xai-key 请求头
API 端点:
POST /api/v1/twitter/publish
xai-key: MY_API_KEY
Content-Type: application/json
请求体:
{
"draftId": "DRAFT_ID",
"accountIds": ["ACCOUNT_ID"]
}
请询问我:
1. 我的 API Key
2. 草稿 ID(或者先创建新草稿)
3. 要发布到的账号 ID
你也可以先调用以下接口显示我的账号:
GET /api/v1/social-sets
然后发布草稿并返回结果。
5. 排程发布草稿
复制此提示词:
你是 xAIcreator API 助手。请帮我排程一个草稿,稍后发布。
基础 URL: https://xaicreator.com/api/v1
认证方式:xai-key 请求头
API 端点:
POST /api/v1/twitter/schedule
xai-key: MY_API_KEY
Content-Type: application/json
请求体:
{
"draftId": "DRAFT_ID",
"scheduledFor": "2026-01-20T10:00:00Z",
"targetAccounts": [
{
"accountId": "ACCOUNT_ID",
"platform": "twitter"
}
]
}
请询问我:
1. 我的 API Key
2. 草稿 ID(或者先创建新草稿)
3. 什么时候发布(UTC 日期时间)
4. 发布到哪个账号/平台
你也可以先调用以下接口显示我的账号:
GET /api/v1/social-sets
注意:时间必须使用 ISO 8601 格式(UTC)。每个平台费用为 10 积分。
6. 查看排程列表
复制此提示词:
你是 xAIcreator API 助手。请帮我查看我的排程发布列表。
基础 URL: https://xaicreator.com/api/v1
认证方式:xai-key 请求头
API 端点:
GET /api/v1/twitter/schedule
xai-key: MY_API_KEY
请询问我的 API Key,然后调用 API 显示所有我的排程发布,包括草稿标题、预定时间和目标平台。
Agent 快速参考
| 操作 | 方法 | 端点 |
|---|---|---|
| 邮箱登录 | POST | /api/v1/auth/login |
| Twitter OAuth URL | POST | /api/v1/auth/oauth/twitter/url |
| Twitter OAuth 回调 | POST | /api/v1/auth/oauth/twitter/callback |
| 获取 Social Set 列表 | GET | /api/v1/social-sets |
| 创建草稿 | POST | /api/v1/twitter/drafts |
| 发布草稿 | POST | /api/v1/twitter/publish |
| 排程草稿 | POST | /api/v1/twitter/schedule |
| 查看排程 | GET | /api/v1/twitter/schedule |
| 删除排程 | DELETE | /api/v1/twitter/schedule?draftId=xxx |