API reference

API reference · Credits

Buy a price lock

POST/api/account/price-locksSigned in session

Moves amountMicros from the balance into a new lock on the model and charges the premium beside it, in one transaction. 403 `price_locks_off` while the operator has not offered locks, and 403 `holder_only` on a deployment with $ANTI holder tiers when the signed in wallet does not hold the lowest tier (a lock already bought is honoured); 400 `model_not_lockable` for an autopilot, a router, an alias, a free or unpriced model; 402 `not_funded` before a first deposit and `insufficient_credits` when the balance cannot cover the credit and the premium; 409 `price_lock_exists` for a second open lock on one model, `price_lock_limit` past 20 open locks, and `price_lock_capacity` when the operator's exposure cap has no room. Same origin only.

Request body

application/json, required

Request body fields
FieldTypeWhat it is
modelrequiredstringThe model id to lock.
amountMicrosrequiredintegerCredit to lock, in micro dollars: whole cents.
daysrequiredintegerWhole days, 1 to the offer's maxDays.

Example

{
  "model": "antimatter/auto",
  "amountMicros": 0,
  "days": 0
}

Answer 201

The lock, as bought.

Fields of the 201 answer
FieldTypeWhat it is
lockrequiredobject
lock.idinteger
lock.modelIdstring
lock.cardobjectThe billed rates frozen on the day the lock was bought.
lock.card.promptPer1MnumberUSD per 1M input tokens.
lock.card.completionPer1MnumberUSD per 1M output tokens.
lock.card.cacheReadPer1Mnumber or nullNull when none was published; cached input then bills at the input rate.
lock.card.cacheWritePer1Mnumber or null
lock.creditMicrosintegerThe prepaid credit moved into the lock.
lock.premiumBpsinteger
lock.premiumMicrosintegerCharged once at purchase as its own ledger line; never refunded.
lock.daysinteger
lock.statusstringOne of "open", "expired".
lock.createdAtinteger
lock.expiresAtinteger
lock.closedAtinteger or null
lock.returnedMicrosinteger or nullWhat went back to the balance at expiry.
lock.balanceMicrosintegerWhat the lock can still spend, open holds taken off.
lock.heldMicrosintegerHeld for requests in flight.
lock.spentMicrosintegerSpent by requests the lock paid for.
lock.marketobject or nullThe model's billed card today, for an open lock; null when it is not priced now.
lock.market.promptPer1MnumberUSD per 1M input tokens.
lock.market.completionPer1MnumberUSD per 1M output tokens.
lock.market.cacheReadPer1Mnumber or nullNull when none was published; cached input then bills at the input rate.
lock.market.cacheWritePer1Mnumber or null

Errors

  • 400OpenAI shaped error.
  • 401OpenAI shaped error.
  • 402OpenAI shaped error.
  • 403OpenAI shaped error.
  • 404OpenAI shaped error.
  • 409OpenAI shaped error.
  • 429OpenAI shaped error.

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter