Clew API Docs

AI provider gateway — route requests through api.clew-code.org with usage tracking, API key auth, and rate limiting.

Base URL: https://api.clew-code.org

Introduction

Clew API provides unified access to multiple AI providers (DeepSeek, OpenAI, Groq, Mistral, etc.) through a single OpenAI-compatible endpoint. It handles authentication, rate limiting, usage tracking, and billing.

Quick Start

# 1. Create account
curl -X POST https://api.clew-code.org/v1/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"yourpassword"}'

# 2. Login to get token
TOKEN=$(curl -s -X POST https://api.clew-code.org/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"[email protected]","password":"yourpassword"}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['token'])")

# 3. Call DeepSeek
curl -X POST https://api.clew-code.org/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"Hello!"}]}'

Authentication

Two authentication methods:

MethodHeaderUse Case
Bearer TokenAuthorization: Bearer <token>Dashboard & personal use (from login)
API KeyX-API-Key: <key>Programmatic access (created in dashboard)

Sign Up

POST/v1/auth/signup
Create a new account (password must be 8+ characters)

Login

POST/v1/auth/login
Login with email + password, returns session token

Get Profile

GET/v1/auth/me
Get current user profile and usage stats
Requires: Bearer token

Password Reset

POST/v1/auth/forgot
Request password reset link
POST/v1/auth/reset
Reset password with token

Models

GET/v1/models
List all available AI models with pricing

Supported models:

ModelProviderContextPricing
deepseek-v4-proDeepSeek1M$1.50/$4 per 1M
deepseek-v4DeepSeek1M$0.50/$1.50 per 1M
gpt-5.5OpenAI1M$10/$40 per 1M
groq/llama4Groq100K$0.50/$1 per 1M
mistral/largeMistral128K$2/$6 per 1M

Chat Completions

POST/v1/chat/completions
Send a chat completion request to any supported model (OpenAI-compatible)
Requires: Bearer token or API key

Request Body

FieldTypeRequiredDescription
modelstringyesModel ID from /v1/models
messagesarrayyesArray of {role, content} objects
streambooleannoEnable SSE streaming
max_tokensnumbernoMax tokens in response

Non-Streaming Example

curl -X POST https://api.clew-code.org/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"Hello!"}]}'

Streaming Example

curl -X POST https://api.clew-code.org/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"Hello!"}],"stream":true}'

Response headers include:

Free Auto-Routing

Use clew/free to automatically route to the best available free model. Falls back if rate limited.

curl -X POST https://api.clew-code.org/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"model":"clew/free","messages":[{"role":"user","content":"Hello!"}]}'

OCR — Extract Text from Images

Use clew/ocr to extract text from images. Supports Thai and English. Auto-routes through DeepSeek OCR, NVIDIA VL, or Groq Vision.

curl -X POST https://api.clew-code.org/v1/chat/completions \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"model":"clew/ocr","messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":"https://example.com/document.jpg"}}]}]}'

Choose model: clew/ocr/nvidia, clew/ocr/deepseek

clew/ Prefix

Prefix any model with clew/ — automatically resolves to the correct provider. Browse all 500+ models on the Models page.

# These are equivalent:
{"model":"gpt-4o-mini"}
{"model":"clew/gpt-4o-mini"}

Image Generation

POST/v1/images/generations
Generate images from text prompts
Requires auth

Supported models: minimax-image-01, dall-e-3

curl -X POST https://api.clew-code.org/v1/images/generations \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"model":"minimax-image-01","prompt":"a cute cat"}'

Video Generation

POST/v1/video/generations
Generate videos from text prompts
Requires auth

Supported models: minimax-hailuo-2.3

curl -X POST https://api.clew-code.org/v1/video/generations \
  -H "Authorization: Bearer $TOKEN" \
  -d '{"model":"minimax-hailuo-2.3","prompt":"a cat walking in the park"}'

API Keys

GET/v1/keys
List your API keys
POST/v1/keys
Create a new API key
DELETE/v1/keys/:id
Revoke an API key

Usage

GET/v1/usage
Get usage summary and breakdown by provider
GET/v1/usage/daily?days=30
Get daily usage chart data (fills missing days with zeroes)

Billing

POST/v1/billing/checkout
Upgrade/downgrade tier or get Stripe checkout URL
GET/v1/billing/invoices
Get monthly invoice history derived from usage logs

Telemetry

Anonymous endpoints for Clew Code CLI instances to report usage.

POST/v1/telemetry/ping
Instance heartbeat (no auth required)
POST/v1/telemetry/event
Record a single telemetry event
POST/v1/telemetry/batch
Batch telemetry events
GET/v1/telemetry/stats
Aggregated telemetry stats (admin/enterprise only)

Webhooks

GET/v1/webhooks
List your webhooks
POST/v1/webhooks
Create a webhook
DELETE/v1/webhooks/:id
Delete a webhook

Plugins

GET/v1/plugins
List marketplace plugins (optional: ?tag= or ?q=)
GET/v1/plugins/:name
Get plugin details

Updates

GET/v1/updates
Get latest version
GET/v1/updates/check?current=0.1.0
Check if update is available

Pricing

TierPriceRate LimitToken Limit/Month
Free$010 req/min100K tokens
Pro$10/mo100 req/min5M tokens
Enterprise$100/mo1000 req/minUnlimited

Dashboard

Manage your account at clew-code.org/app/ — view usage, create API keys, manage billing, and more.