Add 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 key
  • velvet-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 to true

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 api key
		"velvet-auth": process.env.VELVET_API_KEY,
    // add custom metadata
    "velvet-metadata-service_name":  "my-service-name",
    // set target url to forward request to provider
		"velvet-target-url": "https://oai.provider.ai/v1/" 
		// add provider headers
		"provider-auth": `Bearer ${process.env.PROVIDER_API_KEY}`,
		"helicone-property-service_name": "my-service-name"
	}
});