craw_AI

Developers

Tài liệu các endpoint công khai của API. Trong Phase 1, API chạy sau SSH tunnel tại http://127.0.0.1:3001.

Xác thực

Gửi API key trong header Authorization: Bearer ck_…. Tạo key ở Dashboard. Khách dùng header X-Guest-Token và chỉ gọi được các model cho phép khách.

Endpoint

MethodĐường dẫnMô tả
POST/v1/chat/completionsChat theo định dạng chat.completion. Nội dung nằm ở choices[0].message.content.
POST/v1/images/generationsTạo ảnh. Mỗi phần tử trong data có b64_json.
POST/v1/videos/generationsTạo job video. Trả về 202 với id và status "queued".
GET/v1/jobs/{id}Xem trạng thái job, output, lỗi và chi phí.
GET/v1/files/{id}Tải file do job tạo ra (video).
GET/v1/modelsDanh sách model đang bật, kèm chi phí credit.
GET/v1/credits/balanceSố dư credit của tài khoản.
GET/v1/usageTối đa 50 job gần nhất.

Ví dụ với curl

curl http://127.0.0.1:3001/v1/chat/completions \
  -H "Authorization: Bearer ck_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "MODEL_SLUG", "messages": [{"role": "user", "content": "Xin chào"}]}'

Thay ck_YOUR_API_KEY bằng key của bạn và MODEL_SLUG bằng một slug trong bảng bên dưới.

Model

SlugLoạiTierKhách dùng đượcCredit / lần
mock-text-1TEXTFREECó10
mock-image-1IMAGEFREECó20
mock-video-1VIDEOFREEKhông5

Đặc tả OpenAPI

Danh sách dưới đây đọc từ docs/openapi.yaml. Tải file đặc tả đầy đủ tại openapi.yaml. Endpoint “Chưa hoàn thiện” chưa hoạt động đầy đủ trên gateway.

MethodĐường dẫnTóm tắtTruy cậpTrạng thái
GET/healthzGateway livenesspublicSẵn sàng
GET/readyzGateway readinesspublicSẵn sàng
POST/v1/auth/registerCreate an accountpublicSẵn sàng
POST/v1/auth/loginLog in and get a session tokenpublicSẵn sàng
POST/v1/auth/logoutEnd the current sessionprincipalSẵn sàng
GET/v1/meThe signed-in userprincipalSẵn sàng
POST/v1/guest/sessionsStart a guest sessionpublicSẵn sàng
GET/v1/api-keysList your API keysuserSẵn sàng
POST/v1/api-keysCreate an API keyuserSẵn sàng
DELETE/v1/api-keys/{id}Revoke an API keyuserSẵn sàng
GET/v1/modelsList enabled modelspublicSẵn sàng
GET/v1/capabilitiesModels grouped by capabilitypublicSẵn sàng
GET/v1/credits/balanceCredit balance of the accountaccountSẵn sàng
GET/v1/usageYour last 50 jobsprincipalSẵn sàng
POST/v1/chat/completionsChat completion (synchronous)principalSẵn sàng
POST/v1/images/generationsImage generation (synchronous)principalSẵn sàng
POST/v1/videos/generationsVideo generation (asynchronous, text or image to video)principalSẵn sàng
POST/v1/stories/generationsStory generation (synchronous)principalSẵn sàng
GET/v1/jobs/{id}Read one jobprincipalSẵn sàng
GET/v1/files/{id}Download the file of a completed video jobprincipalSẵn sàng
GET/v1/admin/providersList providers with their modelsadminSẵn sàng
POST/v1/admin/providersRegister a provideradminSẵn sàng
PATCH/v1/admin/models/{id}Enable or disable a model, or change its credit costadminSẵn sàng
POST/v1/admin/credits/grantGrant credits to an accountadminSẵn sàng
GET/v1/admin/jobsList jobs across all ownersadminSẵn sàng
GET/v1/payments/packagesActive credit packagespublicSẵn sàng
POST/v1/payments/ordersCreate a credit orderuserSẵn sàng
GET/v1/payments/orders/{id}Read one of your ordersuserSẵn sàng
POST/v1/payments/webhooks/sandboxSandbox payment provider webhookpublicSẵn sàng
POST/v1/admin/payments/orders/{id}/confirmConfirm a bank-transfer order by hand (admin)adminChưa hoàn thiện
POST/v1/workflowsCreate a workflow definitionuserSẵn sàng
POST/v1/workflows/templates/{name}Create a workflow from a named templateuserSẵn sàng
POST/v1/workflows/{id}/runsStart a run of a workflowuserSẵn sàng
GET/v1/workflow-runs/{id}Read a workflow run and its stepsuserSẵn sàng
POST/v1/workflow-runs/{id}/cancelCancel a run that has not finisheduserSẵn sàng
POST/v1/assetsUpload a fileaccountChưa hoàn thiện
GET/v1/assets/{id}Read asset metadataaccountSẵn sàng
DELETE/v1/assets/{id}Delete an assetaccountSẵn sàng
GET/v1/assets/{id}/contentDownload asset bytesaccountSẵn sàng

SDK

  • JavaScript: sdk/js
  • Python: sdk/python

Thư mục SDK nằm trong kho mã của dự án. Quản trị viên có thể đặt biến môi trường SDK_REPO_URL để trang liên kết trực tiếp tới các thư mục này.