Build
API basics
JSON over HTTPS under /v1, a tk_ key as a Bearer credential, an Idempotency-Key on every write, and amounts as strings.
Base URL and keys
Every route lives under /v1 on your Tokex host, JSON over HTTPS. Send a key as a Bearer credential: Authorization: Bearer tk_.... Keys start with tk_, carry only the scopes you give them, and are shown once: Tokex stores a hash. A key without the scope for an action gets 403 forbidden.
Idempotency
Every write carries an Idempotency-Key header, so a retry never runs twice. A write without one is refused with 400 invalid_request. After a lost reply, ask what happened to the operation before you retry.
Amounts
Amounts are strings, never JSON numbers, so nothing rounds on the way.
A request
curl
curl "$TOKEX_URL/v1/chat/completions" \ -H "Authorization: Bearer $TOKEX_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -H "Content-Type: application/json" \ -d '{ "model": "auto", "messages": [{"role": "user", "content": "Draft release notes from this diff."}], "max_tokens": 800 }'