Warehouse requests
Warehouse every request to your database.
Log every request to your database. You'll get an object almost identical to the API, plus any additional metadata included in the header.
We support logging for the below endpoints. For everything else, we're a transparent proxy.
Logging for OpenAI
- /v1/chat/completions
- /v1/batches
- v1/files
- /v1/moderations
- /v1/embeddings
Logging for Anthropic
- /v1/messages
Example object
Here's an example annotated metadata object (a single JSONB column).
{
"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": "04dbb0765fc4f92786f4961c3ef22cdf2ef7ec54521338a8ebc5f426def7a130" // one-way hash to differentiate openai api keys
}
Add custom metadata via the header that you can query against. See the custom header guide for more detail.
Updated 25 days ago