Analyze usage & costs

Query your logs from OpenAI and Anthropic

Query logs

We provide an optional AI SQL editor to query your logs. It's useful for handling high-volume databases and complex schemas - like your AI request database.

You can also warehouse logs to your own database, and query them wherever you'd like.


Example use cases

We store a queryable JSON object so you can granularly analyze usage, performance, and costs.

  • Analyze the cost of batch jobs compared to one-off requests
  • Evaluate the performance of a new model before rolling it out to production
  • Identify a subset of requests to export as JSONL (for fine-tuning or evals)

Example metadata

See an annotated example metadata object (a single jsonb column) from one of our AI features. This examples includes keys that are commonly useful to query against.

{
  "cache": {
    "status": "MISS",
    "enabled": true
  },
  "provider": "openai",
  "model": "gpt-4o-2024-05-13",
  "stream": true,
  "environment": "production", // based on api key
  "service": "query-builder", // from velvet-metadata-service header
  "organization_id": "org_01", // from velvet-metadata-organization_id header
  "workspace_id": "work_01", // from metadata header
  "user_id": "user_01", // from metadata header
  "usage": { // actual usage (if cached, will be zero, otherwise == expected_usage)
    "model": "gpt-4o-2024-05-13",
    "total_tokens": 9108,
    "calculated_by": "js-tiktoken",
    "prompt_tokens": 9056,
    "completion_tokens": 52
  },
  "cost": { // actual cost (if cached, will be zero, otherwise == expected_cost)
    "input_cost": 0.04528,
    "total_cost": 0.04606,
    "output_cost": 0.00078,
    "input_cost_cents": 4.528,
    "total_cost_cents": 4.606,
    "output_cost_cents": 0.078
  },
  "expected_usage": { // expected usage (helper to calculate savings)
    "model": "gpt-4o-2024-05-13",
    "total_tokens": 9108,
    "calculated_by": "js-tiktoken",
    "prompt_tokens": 9056,
    "completion_tokens": 52
  },
  "expected_cost": { // expected cost (helper to calculate savings)
    "input_cost": 0.04528,
    "total_cost": 0.04606,
    "output_cost": 0.00078,
    "input_cost_cents": 4.528,
    "total_cost_cents": 4.606,
    "output_cost_cents": 0.078
  },
  "velvet-auth": "sk_velvet_prod_01", // safe prefix to identify velvet api key
  "authorization": "04dcb0766fc4f94586f4961f3ef22cde4ef7ec67521338a4ebc5r426def7a130" // one-way hash to differentiate openai api keys
}

Watch a demo

See the SQL editor in action as we query request logs to analyze usage.