Skip to main content
Velobase is an AI gateway first: point your existing OpenAI or Anthropic SDK at it, and every model call is billed to one of your end-customers’ wallets. It is also a billing ledger (freeze, consume, deduct) for work you price yourself. This quickstart covers the gateway path first, then the billing ledger primitives.
1

Get your API key

  1. Sign in to the Velobase Dashboard.
  2. Create a project if you haven’t already.
  3. Go to Keys and generate a new key.
You can create two kinds of keys:
  • vb_live_ is a project key. Use it server-side and tell Velobase who to bill with the X-Velobase-Customer: <user-id> header.
  • vb_customer_ is a customer-scoped key. It carries its own customer binding, so no header is needed.
2

Fund a customer wallet

Add funds to a customer’s wallet. If the customer does not exist yet, Velobase creates them automatically.amount is a positive integer number of credits: 1 credit = 1 micro-USD, so 1 USD = 1,000,000 credits.
This deposits 1,000,000 credits, which is $1.00.
3

Make a model call

Point your OpenAI or Anthropic SDK at https://api.velobase.io/v1 and pass X-Velobase-Customer to say which wallet to bill. Models are defined per project: in the dashboard, add a model with a public id, your price, and your own upstream provider key, then call it by that id. GET /v1/models lists your project’s models.
Always set max_tokens. Before each call the gateway places a temporary hold on the customer’s wallet (released or settled when the call finishes), and the output part of that hold is sized from max_tokens. Without it the gateway reserves for a large 8,000-token output, so customers need a much bigger balance to pass the 402 check than the call will actually cost.
Velobase forwards the request upstream, settles the real token cost against the customer’s wallet, and returns per-call billing details in the response headers:
  • X-Velobase-Cost-Credits and X-Velobase-Cost-Usd: what this call cost.
  • X-Velobase-Balance-Credits and X-Velobase-Balance-Usd: the wallet balance after the call.
  • X-Velobase-Transaction-Id: the ledger transaction for this call.
  • X-Velobase-Trace-Id: your correlation id, echoed back if you sent one.
Streaming is supported on both endpoints; the cost and usage arrive in the final standard frame of the stream (OpenAI: the last usage chunk; Anthropic: message_delta).
You can list your project’s models with GET /v1/models and review per-call spend with GET /v1/usage. A model whose upstream provider key has not been attached yet returns 402 byok_key_required.
4

Bill work you price yourself (optional)

For work that is not a model call (for example image generation or a fixed-price feature), use the billing ledger primitives directly. Charge a customer in two ways:
  • Use direct deduction when the cost is known upfront.
  • Use staged deduction when the final cost is only known after execution.
Amounts are positive integer credits (1 USD = 1,000,000 credits).
Use this for fixed-price operations such as image generation or a known API call cost.
This deducts 200,000 credits ($0.20) immediately.
5

Check the wallet

Response:
Wallet amounts are reported in credits (1,000,000 credits = 1 USD).

SDKs

Prefer a typed client? Install the Velobase JavaScript SDK and pin the version:
From Python, call the REST endpoints directly (as in the cURL examples above) and use the OpenAI SDK for gateway calls.

Next steps

Funding wallets

Wallet categories, validity periods, and balance breakdown.

Direct deduction

Charge immediately when cost is known.

Staged deduction

Freeze first, then settle the actual cost.

API reference

Complete endpoint reference.