Loading...
Loading...
Compare original and translation side by side
/api/v1/*https://sleek.designAuthorization: Bearer <API_KEY>/api/v1/*application/json/api/v1/*/api/v1/*https://sleek.design/api/v1/*Authorization: Bearer <API_KEY>application/json/api/v1/*| Scope | What it unlocks |
|---|---|
| List / get projects |
| Create / delete projects |
| List components in a project |
| Get chat run status |
| Send chat messages |
| Render component screenshots |
| 权限范围 | 解锁功能 |
|---|---|
| 列出/获取项目 |
| 创建/删除项目 |
| 列出项目中的组件 |
| 获取对话运行状态 |
| 发送对话消息 |
| 渲染组件截图 |
message.textmessage.textscreen_createdscreen_updatedscreen_createdcomponentIds: [screenId]componentIds: [all screen ids]background: "transparent"screen_createdscreen_updatedscreen_createdcomponentIds: [screenId]componentIds: [所有界面ID]background: "transparent"| Method | Path | Scope | Description |
|---|---|---|---|
| | | List projects |
| | | Create project |
| | | Get project |
| | | Delete project |
| | | List components |
| | | Send chat message |
| | | Poll run status |
| | | Render screenshot |
| 请求方法 | 路径 | 权限范围 | 功能描述 |
|---|---|---|---|
| | | 列出项目 |
| | | 创建项目 |
| | | 获取项目详情 |
| | | 删除项目 |
| | | 列出组件 |
| | | 发送对话消息 |
| | | 查询运行状态 |
| | | 渲染截图 |
GET /api/v1/projects?limit=50&offset=0
Authorization: Bearer <key>200{
"data": [
{
"id": "proj_abc",
"name": "My App",
"slug": "my-app",
"createdAt": "2026-01-01T00:00:00Z",
"updatedAt": "..."
}
],
"pagination": { "total": 12, "limit": 50, "offset": 0 }
}GET /api/v1/projects?limit=50&offset=0
Authorization: Bearer <key>200{
"data": [
{
"id": "proj_abc",
"name": "My App",
"slug": "my-app",
"createdAt": "2026-01-01T00:00:00Z",
"updatedAt": "..."
}
],
"pagination": { "total": 12, "limit": 50, "offset": 0 }
}POST /api/v1/projects
Authorization: Bearer <key>
Content-Type: application/json
{ "name": "My New App" }201POST /api/v1/projects
Authorization: Bearer <key>
Content-Type: application/json
{ "name": "My New App" }201GET /api/v1/projects/:projectId
DELETE /api/v1/projects/:projectId → 204 No ContentGET /api/v1/projects/:projectId
DELETE /api/v1/projects/:projectId → 204 No ContentGET /api/v1/projects/:projectId/components?limit=50&offset=0
Authorization: Bearer <key>200{
"data": [
{
"id": "cmp_xyz",
"name": "Hero Section",
"activeVersion": 3,
"versions": [{ "id": "ver_001", "version": 1, "createdAt": "..." }],
"createdAt": "...",
"updatedAt": "..."
}
],
"pagination": { "total": 5, "limit": 50, "offset": 0 }
}GET /api/v1/projects/:projectId/components?limit=50&offset=0
Authorization: Bearer <key>200{
"data": [
{
"id": "cmp_xyz",
"name": "Hero Section",
"activeVersion": 3,
"versions": [{ "id": "ver_001", "version": 1, "createdAt": "..." }],
"createdAt": "...",
"updatedAt": "..."
}
],
"pagination": { "total": 5, "limit": 50, "offset": 0 }
}message.textPOST /api/v1/projects/:projectId/chat/messages?wait=false
Authorization: Bearer <key>
Content-Type: application/json
idempotency-key: <optional, max 255 chars>
{
"message": { "text": "Add a pricing section with three tiers" },
"imageUrls": ["https://example.com/ref.png"],
"target": { "screenId": "scr_abc" }
}| Field | Required | Notes |
|---|---|---|
| Yes | 1+ chars, trimmed |
| No | HTTPS URLs only; included as visual context |
| No | Edit a specific screen; omit to let AI decide |
| No | Sync wait mode (default: false) |
| No | Replay-safe re-sends |
message.textPOST /api/v1/projects/:projectId/chat/messages?wait=false
Authorization: Bearer <key>
Content-Type: application/json
idempotency-key: <可选,最多255个字符>
{
"message": { "text": "添加包含三个套餐的定价板块" },
"imageUrls": ["https://example.com/ref.png"],
"target": { "screenId": "scr_abc" }
}| 字段 | 是否必填 | 说明 |
|---|---|---|
| 是 | 至少1个字符,自动去除首尾空格 |
| 否 | 仅支持HTTPS URL;作为视觉参考上下文 |
| 否 | 编辑指定界面;留空则由AI决定编辑哪个界面 |
| 否 | 同步等待模式(默认:false) |
| 否 | 可安全重发请求,避免重复操作 |
wait=falsewait=false202 Acceptedresulterror{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "/api/v1/projects/proj_abc/chat/runs/run_111"
}
}202 Acceptedresulterror{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "/api/v1/projects/proj_abc/chat/runs/run_111"
}
}wait=truewait=true200202{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "I added a pricing section with...",
"operations": [
{ "type": "screen_created", "screenId": "scr_xyz", "screenName": "Pricing" },
{ "type": "screen_updated", "screenId": "scr_abc" },
{ "type": "theme_updated" }
]
}
}
}200202{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "我添加了一个包含...的定价板块",
"operations": [
{ "type": "screen_created", "screenId": "scr_xyz", "screenName": "Pricing" },
{ "type": "screen_updated", "screenId": "scr_abc" },
{ "type": "theme_updated" }
]
}
}
}GET /api/v1/projects/:projectId/chat/runs/:runId
Authorization: Bearer <key>data{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "..."
}
}result{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "...",
"operations": [...]
}
}
}error{
"data": {
"runId": "run_111",
"status": "failed",
"statusUrl": "...",
"error": { "code": "execution_failed", "message": "..." }
}
}queuedrunningcompleted | failedGET /api/v1/projects/:projectId/chat/runs/:runId
Authorization: Bearer <key>data{
"data": {
"runId": "run_111",
"status": "queued",
"statusUrl": "..."
}
}result{
"data": {
"runId": "run_111",
"status": "completed",
"statusUrl": "...",
"result": {
"assistantText": "...",
"operations": [...]
}
}
}error{
"data": {
"runId": "run_111",
"status": "failed",
"statusUrl": "...",
"error": { "code": "execution_failed", "message": "..." }
}
}queuedrunningcompleted | failedPOST /api/screenshots
Authorization: Bearer <key>
Content-Type: application/json
{
"componentIds": ["cmp_xyz", "cmp_abc"],
"projectId": "proj_abc",
"format": "png",
"scale": 2,
"gap": 40,
"padding": 40,
"background": "transparent"
}| Field | Default | Notes |
|---|---|---|
| | |
| | 1–3 (device pixel ratio) |
| | Pixels between components |
| | Canvas padding |
| | Any CSS color |
"background": "transparent"image/pngimage/webpContent-Disposition: attachmentPOST /api/screenshots
Authorization: Bearer <key>
Content-Type: application/json
{
"componentIds": ["cmp_xyz", "cmp_abc"],
"projectId": "proj_abc",
"format": "png",
"scale": 2,
"gap": 40,
"padding": 40,
"background": "transparent"
}| 字段 | 默认值 | 说明 |
|---|---|---|
| | 支持 |
| | 1–3(设备像素比) |
| | 组件之间的间距(像素) |
| | 画布内边距(像素) |
| | 支持任意CSS颜色值 |
"background": "transparent"image/pngimage/webpContent-Disposition: attachment{ "code": "UNAUTHORIZED", "message": "..." }| HTTP | Code | When |
|---|---|---|
| 401 | | Missing/invalid/expired API key |
| 403 | | Valid key, wrong scope or plan |
| 404 | | Resource doesn't exist |
| 400 | | Validation failure |
| 409 | | Another run is active for this project |
| 500 | | Server error |
data.error| Code | Meaning |
|---|---|
| Organization has no credits left |
| AI execution error |
{ "code": "UNAUTHORIZED", "message": "..." }| HTTP状态码 | 错误代码 | 触发场景 |
|---|---|---|
| 401 | | API密钥缺失/无效/过期 |
| 403 | | 密钥有效,但权限范围或套餐不满足要求 |
| 404 | | 请求的资源不存在 |
| 400 | | 请求参数验证失败 |
| 409 | | 该项目已有一个正在运行的对话 |
| 500 | | 服务器内部错误 |
data.error| 错误代码 | 含义 |
|---|---|
| 组织的可用额度已耗尽 |
| AI执行过程中发生错误 |
1. POST /api/v1/projects → get projectId
2. POST /api/v1/projects/:id/chat/messages → get runId (202)
3. Poll GET /api/v1/projects/:id/chat/runs/:runId
until status == "completed" or "failed"
4. Collect screenIds from result.operations
(screen_created and screen_updated entries)
5. Screenshot each affected screen individually
6. If any screen_created: also screenshot all project screens combined
7. Show all screenshots to the user1. POST /api/v1/projects → 获取projectId
2. POST /api/v1/projects/:id/chat/messages → 获取runId(状态码202)
3. 轮询GET /api/v1/projects/:id/chat/runs/:runId
直到状态变为"completed"或"failed"
4. 从result.operations中收集screenIds
(包含screen_created和screen_updated的条目)
5. 为每个受影响的界面单独生成截图
6. 如果有新界面创建:同时生成项目所有界面的组合截图
7. 向用户展示所有截图1. POST /api/v1/projects/:id/chat/messages?wait=true
→ blocks up to 300s
→ 200 if completed, 202 if timed out
2. If 202, fall back to Flow 1 polling with the returned runId
3. On completion, screenshot and show affected screens (see screenshot delivery rule)1. POST /api/v1/projects/:id/chat/messages?wait=true
→ 最多阻塞300秒
→ 运行完成返回200,超时返回202
2. 如果返回202,使用返回的runId切换到流程1进行轮询
3. 运行完成后,按照截图交付规则生成并展示受影响界面的截图1. GET /api/v1/projects/:id/components → find screenId
2. POST /api/v1/projects/:id/chat/messages
body: { message: { text: "..." }, target: { screenId: "scr_xyz" } }
3. Poll or wait as above
4. Screenshot the updated screen and show it to the user1. GET /api/v1/projects/:id/components → 找到screenId
2. POST /api/v1/projects/:id/chat/messages
请求体:{ message: { text: "..." }, target: { screenId: "scr_xyz" } }
3. 按照上述方式轮询或等待
4. 为更新后的界面生成截图并展示给用户idempotency-keyPOST /api/v1/projects/:id/chat/messages
idempotency-key: my-unique-request-id-abc123idempotency-keyPOST /api/v1/projects/:id/chat/messages
idempotency-key: my-unique-request-id-abc123409 CONFLICT409 response → poll existing run → completed → send next message409 CONFLICT收到409响应 → 轮询现有运行 → 运行完成 → 发送下一条消息limitoffsetpagination.totalGET /api/v1/projects?limit=10&offset=20limitoffsetpagination.totalGET /api/v1/projects?limit=10&offset=20| Mistake | Fix |
|---|---|
Sending to | Add |
| Using wrong scope | Check key's scopes match the endpoint (e.g. |
| Sending next message before run completes | Poll until |
Using | It blocks 300s max; have a fallback to polling for |
HTTP URLs in | Only HTTPS URLs are accepted |
Assuming | |
| 错误操作 | 修复方案 |
|---|---|
发送请求到 | 为每个请求添加 |
| 使用了错误的权限范围 | 检查密钥的权限范围是否与端点匹配(例如:发送消息需要 |
| 上一个对话运行完成前发送新消息 | 轮询直到状态变为 |
长时间生成任务使用 | 最多阻塞300秒;需为返回202的情况准备轮询降级方案 |
| 仅支持HTTPS URL |
假设 | |