Generates HTTP headers required for AI Gateway requests, including Stripe customer identifiers for usage attribution and billing.
// Source: https://github.com/mperkins0155/giselle | License: Apache-2.0 | Copyright 2024 ROUTE06, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import type { TeamWithSubscription } from "@/services/teams";
/**
* Build AI Gateway headers for billing attribution.
* This function creates headers required for AI Gateway requests,
* including Stripe customer ID for usage tracking.
*/
export function buildAiGatewayHeaders(
team: TeamWithSubscription | null,
): Record<string, string> {
const headers: Record<string, string> = {
"http-referer":
process.env.AI_GATEWAY_HTTP_REFERER ?? "https://giselles.ai",
"x-title": process.env.AI_GATEWAY_X_TITLE ?? "Giselle",
};
const stripeCustomerId = team?.activeCustomerId ?? undefined;
if (stripeCustomerId !== undefine
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key