Drop-in · auto-injection · MIT-licensed

One drop-in client.
Every Cartie header — automatic.

Stop pasting headers on every request. Set cartie.set_tenant("marketing") once at startup. Every subsequent call to OpenAI / Anthropic carries the attribution + egress gate headers automatically.

Single-file Python + TypeScript SDKs. Zero dependencies beyond the upstream LLM client. Just curl into your repo.

Python · in 3 lines
curl -O https://cartieai.com/api/sdk/cartie.py
pip install openai
# That's it. import cartie in your code.
import cartie
cartie.set_proxy(key="ck_live_...")
cartie.set_tenant("marketing")

client = cartie.openai()                 # drop-in for openai.OpenAI()
client.chat.completions.create(
    model="gpt-5.2",
    messages=[{"role": "user", "content": "Draft a blog headline"}],
)

# Egress gate (refuse cross-cloud bleed):
with cartie.egress(source="gcp", dest="aws", data_gb=1024,
                   token_pct=0.05, enforce=True):
    # If verdict is rose, proxy returns 412 BEFORE the upstream call.
    client.chat.completions.create(model="gemini-3-flash", ...)
TypeScript · in 3 lines
curl -O https://cartieai.com/api/sdk/cartie.ts
npm install openai
# That's it. import * as cartie from './cartie' in your code.
import * as cartie from './cartie';
cartie.setProxy({ key: process.env.CARTIE_KEY! });
cartie.setTenant('marketing');

const client = cartie.openai({ apiKey: process.env.OPENAI_KEY! });
await client.chat.completions.create({
  model: 'gpt-5.2',
  messages: [{ role: 'user', content: 'Hello' }],
});

// Egress gate inside an async scope:
await cartie.withEgress(
  { source: 'gcp', dest: 'aws', dataGB: 1024, tokenPct: 0.05, enforce: true },
  () => client.chat.completions.create({ model: 'gemini-3-flash', ... }),
);

What gets auto-injected

Every header below is added to your OpenAI / Anthropic calls when the corresponding setter is configured. Skip the setter → header is omitted.

HeaderConfigure withWhat it does
X-Cartie-Keyset_proxy(key=…)Authenticate the proxy. Required for every call.
X-Cartie-Tenantset_tenant("marketing")Per-department chargeback. Splits a shared bill.
X-Cartie-Source-Cloudset_egress(source=…)Egress preflight: source cloud (aws / gcp / azure / snowflake).
X-Cartie-Dest-Cloudset_egress(dest=…)Egress preflight: destination cloud.
X-Cartie-Data-GBset_egress(data_gb=…)Payload size for the preflight calculation.
X-Cartie-Token-Budget-Pctset_egress(token_pct=…)Tokens generated per GB of input (default 10%).
X-Cartie-Egress-Enforceset_egress(enforce=True)When true, proxy 412s rose verdicts before forwarding.

View the full source

Could not load the SDK source. Refresh the page or visit the raw file directly.
Zero per-call boilerplate
Set the tenant once at app startup. Every call inherits it — no manual headers, no missed attributions.
Drop-in compatible
Returns the standard OpenAI / Anthropic client. All methods, all params, all streaming — unchanged.
Single file. MIT.
No PyPI / npm install. Just curl the file into your repo and import. ~250 lines. Auditable in 5 minutes.

Generate your first proxy key in 60 seconds

Sign in, click "New proxy key" in the LLM Proxy panel, copy the secret into cartie.set_proxy(key=…), and you're live.

We value your privacy. Cookies help us improve your experience. Learn more

Install CARTIEAI

Add to your home screen for quick access and offline support