Gateway API Reference
Base URL: https://api.clawpipe.ai. The gateway is an OpenAPI 3.1 compliant service running on Cloudflare Workers.
Authentication
The API supports two authentication methods:
- API Key (Bearer) — for SDK and programmatic access. Pass as
Authorization: Bearer cp_xxxwithX-Project-Idheader. - JWT Cookie — for dashboard and browser access. Set via
clawpipe_sessionHttpOnly Secure cookie after login.
API keys are hashed with SHA-256 and never stored in plaintext. Provider keys are encrypted at rest in KV.
Prompt Endpoints
Send a prompt through the pipeline and receive a complete response.
Request Body
{
"prompt": "Explain recursion in simple terms",
"provider": "openai",
"model": "gpt-4o-mini",
"system": "You are a helpful tutor",
"maxTokens": 4096,
"temperature": 0.7
}
Response (200)
{
"text": "Recursion is when a function calls itself...",
"tokensIn": 24,
"tokensOut": 156,
"latencyMs": 412
}
Errors: 400 invalid request, 401 auth failed, 502 provider error, 503 provider not configured.
Stream a prompt response via Server-Sent Events. Same request body as /v1/prompt.
Response (200)
Content-Type: text/event-stream
data: Recursion
data: is when
data: a function
data: calls itself...
data: [DONE]
Auth Endpoints
Create a new account. Sets a session cookie on success.
{ "email": "dev@example.com", "password": "min8chars", "name": "Dev" }
Returns: 201 created, 400 validation error, 409 email taken.
Sign in with email and password. Sets a session cookie.
{ "email": "dev@example.com", "password": "min8chars" }
Returns: 200 authenticated, 401 invalid credentials.
Get the current authenticated user profile. Requires session cookie.
Sign out and clear the session cookie.
Redirect to Google OAuth 2.0 flow. Returns 302.
Redirect to GitHub OAuth flow. Returns 302.
Project Endpoints
List all projects for the authenticated user with their roles.
Create a new project. Returns the project with an initial API key.
{ "name": "my-new-project" }
Create a new API key for a project. Requires admin+ role. The key is shown once.
Revoke an API key. Requires owner role.
Rotate an API key. Issues a new key and invalidates the old one. Requires owner role.
Analytics Endpoints
Aggregate statistics for the project: total requests, tokens, cost, cache hit rate.
Per-provider and per-model request counts and cost breakdown.
Daily cache hit rates and savings data.
Daily routing decisions by model, showing how the self-learning router is distributing traffic.
Weights Endpoints
Get the learned router weights for the project.
Save updated router weights.
{ "weights": [{ "provider": "openai", "model": "gpt-4o", "score": 0.85 }] }
Health Check
No authentication required. Returns gateway status.
{ "status": "ok", "service": "clawpipe-gateway" }