Velvet config

Update your OpenAI config to use Velvet.

Domain and baseURL

Your Velvet gateway domain is gateway.usevelvet.com.

The baseURL for using the gateway with OpenAI is:

https://gateway.usevelvet.com/api/openai/v1/

Follow client config examples to modify the baseURL and headers.


Client config examples

Node.js OpenAI Client config:

import OpenAI from "openai";

const openai = new OpenAI({
	baseURL: "https://gateway.usevelvet.com/api/openai/v1/",
	defaultHeaders: {
		"velvet-auth": process.env.VELVET_API_KEY
	}
});

Expanded Node.js OpenAI Client config.

This example provides additional headers for Velvet (metadata), and 3rd party proxies like 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-target-url": "https://oai.helicone.ai/v1/" // set target url to forward request to helicone
		"velvet-metadata-service_name":  "my-service-name",
		// add helicone headers
		"helicone-auth": `Bearer ${process.env.HELICONE_API_KEY}`,
		"helicone-property-service_name": "my-service-name"
	}
});

Ruby OpenAI Client config with both Velvet and Helicone settings:

OpenAI::Client.new(
    uri_base: "https://gateway.usevelvet.com/api/openai/v1/",
    extra_headers: {
			"velvet-auth": "VELVET_API_KEY"
			"velvet-target-url": "https://oai.helicone.ai/v1/" # set target url to forward request to helicone
      "Helicone-Auth": "Bearer HELICONE_API_KEY", # keep your helicone api key
    }
)


# you can use velvet-metadata-* headers along with helicone-property-* headers

extra_headers: {
	"velvet-metadata-service_name": "my-service-name"
  "helicone-property-service_name": "my-service-name",
}

⚠️

Complete setup before deploying client changes

Complete all steps in the 'Warehouse LLM calls' guide before deploying AI client changes.


Velvet headers

The gateway supports various HTTP headers to customize your logs.

  • 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)

Forward requests to Helicone

To use Helicone, add a velvet-target-url header that points to the Helicone gateway base URL.

Send and log additional data using velvet-metadata-* or helicone-property-* headers.


Supported endpoints

Currently, the Velvet gateway supports OpenAI endpoints. If there are additional endpoints or providers you want supported, email [email protected] with your requirements.


OpenAI logging support

Requests, responses, and metadata from these endpoints will be logged to your database.

  • /v1/chat/completions
  • /v1/moderations

OpenAI transparent proxy support

For additional OpenAI endpoints, we use rewrites to forward requests. You won’t lose any OpenAI functionality.

For requests with only an OpenAI key, we’ll rewrite:

  • source: https://contraption-gateway.usevelvet.com/api/openai/v1/
  • destination: https://api.openai.com/v1/

For requests with both an OpenAI API key (e.g. Authorization header) and a 3rd-party header like Helicone-Auth, we’ll rewrite:

  • source: https://contraption-gateway.usevelvet.com/api/openai/v1/
  • destination: https://oai.helicone.ai/v1/

Additional endpoints and 3rd-party proxies

We can quickly roll out support for additional endpoints and proxies.

Email [email protected] with your requirements.


What’s Next

Set up a PostgreSQL database to warehouse logs.