Documentation menu · buyer-quickstart

Buyer quickstart

From zero to a receipted call in four steps.

1. Create an account and fund it

Create an account, then add credit under Billing. Balance is held in microdollars; every call draws from it at the price the serving offer lists.

2. Create a key

Under Keys, create a key. You can attach a policy (minimum discount, verification tier, regions, ZDR, objective, masking, caching), daily and monthly budgets, and a model map. The secret is shown once.

shell
export THIN_API_KEY="sk-thin-…"

3. Point your client at the exchange

python
from openai import OpenAI
import os

client = OpenAI(base_url="http://localhost:8787/v1", api_key=os.environ["THIN_API_KEY"])

resp = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash",
    messages=[{"role": "user", "content": "One line on why spreads matter."}],
    extra_body={"thin": {"min_discount": 50}},
)
print(resp.choices[0].message.content)

Model ids are the exchange's canonical ids (vendor/model). Browse them on Markets or call GET /v1/models.

4. Read what happened

Non-streamed responses include a thin object:

json
"thin": {
  "request_id": "req_…",
  "offer_id": "off_…",
  "seller": "s_7f3a",
  "region": "eu",
  "verification": "verified",
  "attempts": 1,
  "rescued": false,
  "hedged": false,
  "cache": "off",
  "masked": 0,
  "usage": { "input_tokens": 812, "output_tokens": 230 },
  "cost_micro": 412,
  "list_cost_micro": 1890,
  "savings_micro": 1478,
  "receipt": "rcp_…"
}

The same facts arrive as headers — x-thin-request-id, x-thin-offer, x-thin-seller, x-thin-attempts, x-thin-cost-micro, x-thin-list-cost-micro, x-thin-verification, x-thin-cache, x-thin-masked. For streams, set stream_options.include_usage: true; the final usage chunk carries the thin field.

Failed calls are free

If every attempt fails you get upstream_failed and are not charged. Check GET /v1/balance for your balance and the key's spend against its budgets.