← DOCS
// RAIL_01 · API_KEY + CREDITS

QUICKSTART.

From zero to your first inference call in under 2 minutes. This rail is OpenAI-compatible — if you already have a working OpenRouter or OpenAI integration, swap two lines and you're done.

STEP 01

GET AN API KEY

Sign in to Bourse and generate a key. Keys start with bs_live_ and authenticate as Authorization: Bearer. You can rotate or revoke any key from the dashboard at any time.

STEP 02

TOP UP CREDITS

Bourse keeps a credit balance per user, denominated in USDC. Two ways to fund:

// FIAT
CARD → USDC

Privy onramp turns your card into USDC in your embedded wallet, then credits your balance. $5 / $20 / $50 / $100 packs.

No prior wallet required. Best for traditional apps.

// CRYPTO
USDC ON SOLANA

Pay USDC on Solana mainnet from any wallet. Server verifies on-chain via Solana Pay reference, balance lands seconds later.

Best for teams already running on Solana.

Both flows fund the same ledger. Calls deduct in micro-USDC at settlement time. Insufficient balance returns HTTP 402 with a link to top up.

STEP 03

MAKE YOUR FIRST CALL

Drop-in OpenAI-compatible. Just swap the base URL and the API key.

curl https://usebourse.xyz/api/v1/chat/completions \
  -H "Authorization: Bearer $BOURSE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemma-3-27b-it",
    "messages": [
      {"role": "user", "content": "Hello, Bourse."}
    ]
  }'
// streaming is on by default — pass stream: false for one-shot JSON
// response headers you'll see on every call:
//   X-Bourse-Provider     "Hugging Face" | "Cerebras" | ...
//   X-Bourse-Model        "Gemma 3 27B"  // human-readable
//   X-Bourse-Model-Id     "huggingface/google/gemma-3-27b-it"

// HOW_BILLING_WORKS

  1. 1. PRE-FLIGHT HOLD. On request, Bourse computes an upper-bound charge from your prompt + max_tokens and atomically holds that amount. Insufficient balance returns 402 immediately, before any upstream call.
  2. 2. ROUTE + FAILOVER. Your model resolves to an ordered list of provider offers (cheapest first). Forwarded to the cheapest. If that errors, next candidate, hold topped up if priced higher.
  3. 3. SETTLE. On stream end (or response receive), Bourse computes the actual charge from token usage and reconciles the hold. Overestimation is refunded to your balance, no manual action needed.
  4. 4. CREATOR FEE. A fraction of the gross (set by the model creator at listing) routes to the model's on-chain revenue vault for buyback-and-burn. The rest pays the upstream provider.

// STATUS_CODES

200OKInference returned. Hold reconciled to actual charge.
401UNAUTHORIZEDMissing or revoked Bourse key.
402INSUFFICIENT_QUOTABalance too low for pre-flight hold. Top up and retry.
404MODEL_NOT_FOUNDRequested model has no active provider offer.
502ALL_PROVIDERS_FAILEDEvery candidate in the failover chain errored. Hold released.