API Reference

OpenAI-compatible gateway + per-tenant cost attribution + real-time circuit breakers

Quick Start (2 minutes)

1. Get API key at daylite.ai/dashboard (free, no card)

2. Change your base_url to https://api.daylite.ai/v1

3. Add X-Daylite-Customer header to track costs per customer

curl — with cost attribution
curl https://api.daylite.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "X-Daylite-Customer: customer_123" \
  -H "X-Daylite-Feature: chat" \
  -d '{"model":"llama-3.3-70b","messages":[{"role":"user","content":"Hello"}]}'

# Response headers include:
# X-Daylite-Cost: 0.000420
# X-Daylite-Tokens-In: 12
# X-Daylite-Tokens-Out: 847
# X-Daylite-Customer: customer_123

Platform Features

Unique to Daylite

Per-Customer Cost Attribution

Pass customer ID and feature name in request headers. Get exact cost in USD in response headers. No middleware, no proxy — built into every request.

python — track cost per customer
from openai import OpenAI

client = OpenAI(
    base_url="https://api.daylite.ai/v1",
    api_key="YOUR_API_KEY",
)

# The extra_headers parameter passes attribution data
response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[{"role": "user", "content": "Summarize this document"}],
    extra_headers={
        "X-Daylite-Customer": "customer_123",
        "X-Daylite-Feature": "document-summary",
    },
)

# Response includes cost in headers
# Access via: response.headers["X-Daylite-Cost"]
print(response.choices[0].message.content)

Real-Time Circuit Breakers

Set hard spend limits per tenant. When exceeded, the request is blocked before it reaches the provider — zero cost. Protects against runaway agent loops that can burn thousands in minutes.

curl — set a budget cap
curl -X POST https://api.daylite.ai/v1/budgets \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customer_id": "customer_123",
    "monthly_cap_usd": 500.00,
    "action_on_cap": "block",
    "alert_thresholds": [0.5, 0.8, 0.9]
  }'

# When tenant exceeds $500/month:
# → API returns 429 "Budget exceeded" — provider never called
# → Alerts fire at 50%, 80%, 90% via webhook
# → Protects against runaway agent loops

Usage API

Query usage breakdown by customer, feature, or model. Build your own dashboards or export CSV.

curl — get usage per customer
# All customers
curl https://api.daylite.ai/v1/usage \
  -H "Authorization: Bearer YOUR_API_KEY"

# Specific customer
curl "https://api.daylite.ai/v1/usage?customer=customer_123" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Returns: totalCost, totalRequests, byFeature, byModel, budget status

Inference API

Base URL
https://api.daylite.ai/v1

Python (OpenAI SDK)

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.daylite.ai/v1",
    api_key="YOUR_API_KEY",
)

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[{"role": "user", "content": "What is solar curtailment?"}],
)
print(response.choices[0].message.content)

JavaScript (OpenAI SDK)

typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.daylite.ai/v1",
  apiKey: "YOUR_API_KEY",
});

const response = await client.chat.completions.create({
  model: "llama-3.3-70b",
  messages: [{ role: "user", content: "What is solar curtailment?" }],
});
console.log(response.choices[0].message.content);

Streaming

python — streaming
stream = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[{"role": "user", "content": "Explain inference"}],
    stream=True,
    extra_headers={"X-Daylite-Customer": "customer_123"},
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Models & Pricing

ModelContextStandard (in/out)Batch (in/out)
llama-3.3-70b128K$0.30 / $0.50$0.20 / $0.35
llama-3.1-8b128K$0.04 / $0.06$0.03 / $0.04
deepseek-v3128K$0.35 / $1.00$0.25 / $0.70

Authentication

header
Authorization: Bearer dl-your-api-key

Free key at dashboard. 50K requests/month free on Developer tier.

Custom Headers

HeaderDirectionDescription
X-Daylite-CustomerRequestYour customer ID for cost attribution
X-Daylite-FeatureRequestFeature name for cost breakdown
X-Daylite-CostResponseCost of this request in USD
X-Daylite-Tokens-InResponseInput tokens consumed
X-Daylite-Tokens-OutResponseOutput tokens generated

Error Codes

400Invalid request — check model name and message format
401Invalid API key
402Insufficient credits — top up in dashboard
429Customer budget exceeded — manage via /v1/budgets
502Backend temporarily unavailable

API Endpoints

MethodEndpointDescription
POST/v1/chat/completionsChat completions (streaming supported)
GET/v1/modelsList available models
GET/v1/usagePer-customer usage breakdown
POST/v1/budgetsSet spend caps per customer
POST/api/checkoutPurchase credit packs (Stripe)
Try it in the Playground