10 minutes
Quickstart
Sign up, copy the Costslice key, point your OpenAI client at us, tag three headers. Dollars show up on Tenants.
Create a workspace
Sign in at costslice.com, name the org, copy
cs_live_…. Put it inCOSTSLICE_KEY. KeepOPENAI_API_KEYas the provider key.Python openai
from openai import OpenAI import os client = OpenAI( base_url="https://api.costslice.com/v1", api_key=os.environ["OPENAI_API_KEY"], default_headers={ "x-cs-key": os.environ["COSTSLICE_KEY"], "x-cs-tenant": tenant_id, # opaque id, never an email "x-cs-feature": "support-copilot", "x-cs-env": "prod", }, ) resp = client.chat.completions.create( model="gpt-5.6-terra", messages=[{"role": "user", "content": "Summarize this ticket"}], )Node openai
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.costslice.com/v1", apiKey: process.env.OPENAI_API_KEY, defaultHeaders: { "x-cs-key": process.env.COSTSLICE_KEY, "x-cs-tenant": tenantId, "x-cs-feature": "support-copilot", "x-cs-env": "prod", }, }); const resp = await client.chat.completions.create({ model: "gpt-5.6-terra", messages: [{ role: "user", content: "Summarize this ticket" }], });Vercel AI SDK
import { createOpenAI } from "@ai-sdk/openai"; import { generateText } from "ai"; const openai = createOpenAI({ baseURL: "https://api.costslice.com/v1", apiKey: process.env.OPENAI_API_KEY, headers: { "x-cs-key": process.env.COSTSLICE_KEY!, "x-cs-tenant": tenantId, "x-cs-feature": "support-copilot", "x-cs-env": "prod", }, }); const { text } = await generateText({ model: openai("gpt-5.6-terra"), prompt: "Summarize this ticket", });If tenant/feature change per request, pass headers on the call instead of the client. The three Costslice headers are strings, max 128 characters. Streaming works; we read
usageon the final chunk (we setstream_options.include_usagewhen you stream). If usage is missing we estimate tokens and markcost_source=estimate. Unknown models cost $0 and show as unpriced.
Local proxy
Point base_url at http://127.0.0.1:8788/v1 and keep the same headers. See the README for Next.js + Worker + Postgres.