ClankerBay

Calling providers

Every provider call goes through the gateway, whether it comes from the CLI, a REST client or an MCP client:

{METHOD} https://clankerbay.com/api/v1/gateway/{namespace}/{operation path}
Authorization: Bearer cbk_…
curl -H "Authorization: Bearer $CB_TOKEN" \
  "https://clankerbay.com/api/v1/gateway/hynx-web/search?q=cake+recipes&limit=3"

Request lifecycle

  1. Resolve the namespace and match the method and path to an operation of the active schema version.
  2. Load cached namespace, schema and price metadata (refreshed every 60s, invalidated on change).
  3. Authenticate the token and check the gateway:call scope.
  4. Validate required parameters and the request size.
  5. Check the per-call limit, approval threshold, daily and monthly caps.
  6. Atomically reserve the price: subscription credits first, then prepaid.
  7. Forward the request to the provider with the provider's credentials.
  8. Record status, latency and the actual charge.
  9. Write a durable usage event to the journal, then return the response.

Request headers

X-Clankerbay-Max-CreditsReject the call (409 price_exceeds_max) if it costs more than this
X-Clankerbay-Approve: trueApprove a call at or above your approval threshold
X-Clankerbay-Schema-VersionSchema version the client was built against; rejected with 409 schema_changed if the operation changed incompatibly since
Idempotency-KeyDeduplicate retries for 24 hours

Hop-by-hop headers, cookies, Authorization and all X-Clankerbay-* headers are removed before the request is forwarded.

Response headers

X-Clankerbay-Request-IdMatches the usage record
X-Clankerbay-Credits-ChargedTotal credits charged
X-Clankerbay-Credits-Subscription…of which from subscription credits
X-Clankerbay-Credits-Prepaid…of which from prepaid credits
X-Clankerbay-Upstream-StatusThe provider's HTTP status
X-Clankerbay-Latency-MsProvider latency

The provider's status code and body are returned unchanged. Errors raised by the gateway itself use the standard error envelope.

Charging rules

OutcomeCharged?Usage status
Provider returns 2xx or 3xxYes, the endpoint pricesuccess
Rejected before execution (auth, validation, limits, credits, price check)Nonot executed
Provider returns 4xxNoupstream_error
Provider returns 5xxNoupstream_error
Timeout (per-service, default 15s)Notimeout
Connection failure / DNS / TLSNoconnection_error
Response interrupted mid-streamNoupstream_error

The gateway does not retry requests on your behalf, so a call reaches the provider at most once per attempt. Use Idempotency-Key to retry safely.

Error codes

StatusCode
401unauthenticated, invalid_token
403insufficient_scope, account_suspended, per_call_limit_exceeded
402insufficient_credits, approval_required
404namespace_not_found, operation_not_found
400invalid_arguments
409price_exceeds_max, schema_changed, idempotency_in_progress
413payload_too_large (10 MB request limit)
429rate_limited, daily_cap_exceeded, monthly_cap_exceeded
502 / 504upstream_unreachable, upstream_timeout