API Reference

All endpoints use https://api.codelace.com as the base URL. Authenticated endpoints require a Bearer cl_... token header.

Inference

POST/v1/chat/completions

OpenAI-compatible chat completion. Streaming supported. Works with any OpenAI SDK.

Request body
{
  "model": "anthropic/claude-opus-4.6",
  "stream": true,
  "messages": [
    {"role": "user", "content": "Hello"}
  ]
}
GET/v1/models

List available models on the network.

Response
{
  "data": [
    {"id": "anthropic/claude-opus-4.6", "object": "model"},
    {"id": "openai/gpt-5.4", "object": "model"}
  ]
}

Authentication

POST/api/v1/auth/otp/request

Request a 6-digit email verification code.

Request body
{ "email": "you@company.com" }
Response
{
  "email": "you@company.com",
  "expires_in_sec": 600
}
POST/api/v1/auth/otp/verify

Verify the OTP code and receive an API key.

Request body
{
  "email": "you@company.com",
  "code": "123456"
}
Response
{
  "user_id": "uuid",
  "api_key": "cl_...",
  "email": "you@company.com",
  "credit_balance_usd": 0
}
GET/api/v1/auth/me

Get the authenticated user profile.

Response
{
  "id": "uuid",
  "email": "you@company.com",
  "display_name": "Jane"
}
GET/api/v1/auth/key

List all API keys for the authenticated user.

Response
[
  {
    "id": "uuid",
    "key_prefix": "cl_ab12",
    "name": "production",
    "created_at": "2026-03-01T00:00:00Z"
  }
]
POST/api/v1/auth/key

Create a new API key.

Request body
{ "name": "production" }
Response
{
  "id": "uuid",
  "key_prefix": "cl_ab12",
  "full_key": "cl_ab12...full_key"
}
DELETE/api/v1/auth/key/{keyId}

Revoke an API key.

Customer

GET/api/v1/customer/balance

Get the current credit balance.

Response
{
  "credit_balance_usd": 30.00
}
GET/api/v1/customer/usage

Get consumption stats including recent requests.

Response
{
  "request_count": 42,
  "total_input_token": 50000,
  "total_output_token": 12000,
  "total_cost_usd": 15.50
}
GET/api/v1/customer/payment

Get payment history.

Response
[
  {
    "id": "uuid",
    "amount_usd": 25,
    "status": "completed",
    "created_at": "2026-03-01T00:00:00Z"
  }
]

Stripe

POST/api/v1/stripe/setup

Create a Stripe setup session to save a card without charging it. On first successful setup, the account receives $1 in trial credit.

Response
{
  "checkout_url": "https://checkout.stripe.com/..."
}
POST/api/v1/stripe/checkout

Create a Stripe checkout session to purchase credit. Minimum top-up is $10.

Request body
{ "amount_usd": 25 }
Response
{
  "checkout_url": "https://checkout.stripe.com/..."
}

Public

GET/api/v1/public/pricing

Get model pricing. No authentication required.

Response
[
  {
    "model": "anthropic/claude-opus-4.6",
    "input_per_1m": 2.50,
    "output_per_1m": 12.50
  }
]