Models and enclaves

Five functions read what the API indexes from the chain. None needs a wallet, except account without an argument. Each returns the response of one HTTP route, typed and checked against the API's schema, so the fields are told once, on that route's page.

FunctionReturnsRoute
models(query?)A page of models.GET /v1/models
model(id)One model, by name or address.GET /v1/models/{id}
enclaves(query?)A page of enclaves.GET /v1/enclaves
enclave(key)One enclave with its grants, receipts and earnings.GET /v1/enclaves/{key}
account(wallet?)A wallet's models, enclaves, earnings and calls.GET /v1/accounts/{wallet}

models#

TypeScript
const page = await voynich.models({ sort: 'newest', limit: 10 })
for (const model of page.items) console.log(model.name, model.price.amount, model.status)

const next = page.page.nextCursor ? await voynich.models({ cursor: page.page.nextCursor }) : null
FieldMeaning
sort'calls' | 'newest' | 'price'

The order. calls by default.

limitnumber

Models per page, 1 to 100. 24 by default.

cursorstring

The nextCursor of the page before.

A page is { items, page: { nextCursor, hasMore }, asOf }. nextCursor is null on the last page.

model#

TypeScript
const model = await voynich.model('sketch-32')
console.log(model.manifest.labels)

Takes the model's name or address. Throws an ApiClientError with MODEL_NOT_FOUND when there is none.

enclaves and enclave#

TypeScript
const enclaves = await voynich.enclaves()
const detail = await voynich.enclave(enclaves.items[0]!.address)
console.log(detail.earnings)

enclaves takes limit and cursor as models does. It lists live and reachable enclaves first; each Enclave's reachable and lastSeen are told in Reachability. enclave takes an enclave's address or its signing key and returns { enclave, grants, receipts, earnings }. It throws ENCLAVE_NOT_FOUND when there is none.

account#

TypeScript
const mine = await voynich.account()
const theirs = await voynich.account(wallet)

Without an argument it reads the signer's own wallet, and throws WALLET_REQUIRED when the client has none. It returns { wallet, models, ownerEarnings, enclaves, operatorEarnings, calls }. A call whose status is refundable can be passed to refund.

Every other route#

voynich.api is the typed client of the whole HTTP API: the model's ciphertext (api.weights), its enclaves and receipts (api.modelEnclaves, api.modelReceipts), receipts and calls (api.receipt, api.call, api.answer), the counts (api.stats), the configuration (api.config) and every transaction build. Each method is named after its route's operation in the route list.