credits

Atomic credit debit + ledger append

Called by the agent app's chat route in a fire-and-forget after() tail task once a chat turn's stream completes.

Idempotency: replays of the same chat_request_id return { status: "duplicate", credit_cost, balance_after } without debiting again — the unique partial index on credit_transaction.chat_request_id is the source of truth.

Free-tier callers (no credit_balance row) get { status: "no_balance", ... } instead of an error — the agent's free-tier message-count gate handles those users via a different path.

post/credits/consume

Request

  • Base URL: https://api.autron.ai
  • URL: https://api.autron.ai/credits/consume
  • Auth: API key in header Authorization

Request body

chat_request_idstring
modelstring
user_public_idstring
input_tokensinteger
output_tokensinteger
cached_input_tokensinteger
cached_output_tokensinteger
long_context_input_tokensinteger
long_context_output_tokensinteger
long_context_cached_input_tokensinteger
audio_secondsnumber
sourcestring
internalboolean
on_behalf_of_company_public_idstring
on_behalf_of_seller_public_idstring

Response

Success

Changes

No recorded changes to this operation across all 1 revision of this API.