Request logging
Warehouse every request to your database.
Log requests 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
Proxy notes
You'll have full API access. For endpoints where we don't support warehousing, we act as a transparent proxy.
Headers that contain auth or api-key information (e.g authorization, velvet-auth, x-api-key) get redacted in the logs. They’ll show up as [REDACTED] or stripped entirely from the data.
We don’t store your OpenAI key, it’s passed along via the Authorization header to OpenAI. We do create a SHA-256 hash on the Authorization header value and store it in the Metadata column so that you can differentiate keys safely (e.g. you need to differentiate users/apps/cost analysis across rotating keys/etc).
Email [email protected] with any questions.
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 16 days ago