10 minutes

Quickstart

Sign up, copy the Costslice key, point your OpenAI client at us, tag three headers. Dollars show up on Tenants.

  1. Create a workspace

    Sign in at costslice.com, name the org, copy cs_live_…. Put it in COSTSLICE_KEY. Keep OPENAI_API_KEY as the provider key.

  2. 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"}],
    )
  3. 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" }],
    });
  4. 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 usage on the final chunk (we set stream_options.include_usage when you stream). If usage is missing we estimate tokens and mark cost_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.