Anywear CLI 与 REST API
通过终端、脚本或编程智能体创建试穿链接。在浏览器中登录一次后,传入服装图片 URL,即可用一条命令打开试衣间。
正在使用 Claude 或 ChatGPT 等聊天应用?请改为通过 MCP 连接。 MCP 设置
安装
从 npm 安装官方 anywear 软件包,或通过 npx 免安装运行。需要在 macOS 或 Linux 上安装 Node.js 22 或更高版本。
全局安装
npm i -g anywear免安装运行
npx anywear login命令
anywear login- 打开浏览器登录 Anywear 并授权 CLI。登录状态会保存在此电脑上。
anywear try-on IMAGE_URL --open --wait- 为服装图片创建试穿链接。--open 会在浏览器中打开链接,--wait 会等待试穿场次结束,并输出所用的秒数和积分。
anywear status LINK_ID- 显示链接的状态,以及通过该链接开启的试穿场次。
anywear list- 列出您最近的试穿链接。
anywear whoami- 显示当前登录的账户及其积分余额。
anywear logout- 退出登录,并从此电脑中删除已保存的登录信息。
将 IMAGE_URL 替换为 JPEG、PNG 或 WebP 图片的直链,将 LINK_ID 替换为 CLI 输出的 ID。
在编程智能体中使用
Claude Code、Codex 等可运行终端命令的编程智能体可以直接使用 CLI。请将以下指令粘贴给智能体:
Read https://anywear.studio/mcp-guide.txt and set up the Anywear CLI on this computer. Let me sign in in my browser, then create a try-on link for the garment I choose.价格
- 每个试穿场次最长 30 秒,按秒计费:每秒 1 积分,最低按 10 秒计费。
- 试穿场次开始时将冻结 30 积分,场次结束后,未使用的部分将退回您的余额。
- 创建链接免费,未开始的试穿场次不产生任何费用。
- 在试穿场次内切换服装不额外收费。
- 链接在 24 小时后失效。每个账户每小时最多可创建 20 个链接。
隐私与控制
- AI 应用无法开启您的摄像头、启动试穿场次或购买任何商品。只有您本人可以在自己的浏览器中启动试穿场次。
- 该应用可以查看您的电子邮箱地址、积分余额以及为您的账户创建的试穿链接,但绝不会接收您的摄像头视频。
- 您可以随时在账户页面断开应用的连接,其访问权限将立即终止。
REST API
CLI 基于一个精简的 REST API 构建,您也可以在自己的代码中调用该 API。每个请求都需在 Authorization 请求头中携带 OAuth 2.1 访问令牌。以下技术参考文档为英文。
curl https://anywear.studio/api/v1/tryon/links \
-H "Authorization: Bearer $ANYWEAR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"image_url": "https://shop.example/images/jacket.jpg"}'GET /api/v1/account- The connected account: email, credits, rooms_available, pricing and top_up_url.
POST /api/v1/tryon/links- Create a try-on link. JSON body: {"image_url": "https://…/garment.jpg", "title": "optional"}. Returns 201 with the link, including its url and expires_at.
GET /api/v1/tryon/links?limit=10- The account's most recent try-on links (limit 1–50).
GET /api/v1/tryon/links/{id}- One link: status (waiting_for_user, in_progress, finished or expired), its latest five rooms with seconds_used, seconds_billed (minimum included) and credits_charged, and credits_charged / rooms_total across every room.
{"error": {"code": "not_found", "message": "Try-on link not found"}}OAuth 端点
Anywear 是支持动态客户端注册和 PKCE 的 OAuth 2.1 授权服务器。客户端均为公共客户端,因此不会签发客户端密钥。
GET /.well-known/oauth-authorization-server- Authorization server metadata (RFC 8414).
GET /.well-known/oauth-protected-resource- Protected resource metadata (RFC 9728).
POST /api/oauth/register- Dynamic client registration (RFC 7591). Send redirect_uris; returns a client_id.
GET /oauth/authorize- Authorization code flow with PKCE (S256). The user signs in and chooses Allow.
POST /api/oauth/token- grant_type authorization_code or refresh_token. Access tokens last 1 hour; refresh tokens 60 days.
POST /api/oauth/revoke- Token revocation (RFC 7009). A refresh token ends the whole connection; an access token ends only itself.