Custom metadata
Add custom metadata that can be queried.
Include custom metadata
Velvet logs the identical object you would get from the LLM, plus cost calculations.
You can include additional values you want logged with each request.
Use cases
- Include the user ID, org ID, model ID, and version ID
- Trace specific features, models, endpoints
- Differentiate between production and development
Add metadata to your header
Customize your logs with HTTP headers, examples below. This lets you query logs more granularly.
velvet-auth
— API keyvelvet-metadata-*
— send any metadata, key/values are stored in a JSONB column,velvet-request-id
— customize the request id format (default:log_<16char_nanoid>
)velvet-target-url
— forward the request to an endpoint other than OpenAI (e.g. Helicone)velvet-cache-enabled
— enable identical request caching by setting totrue
Forward requests
To forward requests to an additional third party, add a velvet-target-url
header that points to that proxy's base URL.
Forward data using a provider-property-*
header.
Example header
Here's an example header with additional metadata and forwarding to an additional third party proxy (helicone).
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://gateway.usevelvet.com/api/openai/v1/",
defaultHeaders: {
"velvet-auth": process.env.VELVET_API_KEY, // velvet api key
"velvet-metadata-service_name": "my-service-name", // add custom metadata
"velvet-target-url": "https://oai.helicone.ai/v1/" // set target url to forward request to provider
"helicone-auth": "Bearer <HELICONE_API_KEY>", // add provider headers
"helicone-property-service_name": "my-service-name"
}
});
Updated 3 days ago