Skip to content
KYZEN DOCUMENTATIONLaunch app

DocsProductsGateway

API reference

Every endpoint, the Pro and Flash models, the errors and the limits.

Base URL
app.kyzen.network/v1
Format
OpenAI-compatible
Models
Pro, Flash
Rate limit
60 a minute

#Base URL

The Gateway API follows OpenAI’s chat completions API. OpenAI’s client libraries work with it once the base URL and the key are set. From a first top-up to a first request, step by step: Use the Gateway.

DetailRule
Base URLhttps://app.kyzen.network/v1
KeyAuthorization: Bearer $KYZN_KEY, on the endpoints marked below; a key starts with kyzn_
Request bodiesJSON, at most 1,000,000 bytes
AnswersJSON, never cached; a streamed answer as server-sent events
Chargex-kyzen-charge: the request’s charge in $KYZN, on chat completions only, when the answer is not streamed
BrowsersAny origin may call the API with the Authorization and Content-Type headers only; retry-after and x-kyzen-charge are readable. A browser client library that adds other headers fails the browser’s preflight check; plain fetch works
RegionsThe endpoints that act follow the app’s region rule (Where the app opens)
Read a request's charge
curl -i https://app.kyzen.network/v1/chat/completions \
  -H "Authorization: Bearer $KYZN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"flash","messages":[{"role":"user","content":"Which stage binds?"}]}'

What a request costs, and when it is settled: Balance and settlement.

#Endpoints

Every path sits under the base URL. Endpoints marked with a key read the wallet from it; the rest need none.

EndpointKeyRegion ruleGives
GET /v1/healthNoNook, the network, and live: whether the network has a recorded deployment
GET /v1/modelsNoNoThe tiers, with their prices per million tokens
GET /v1/statsNoNoRequests served, models online, $KYZN burned in the last 24 hours, the $KYZN price
GET /v1/postsNoNoThe latest 50 posts drafted from live data that pass the copy rules; ?kind=weekly, gateway or rotation for one kind
GET /v1/balance/{wallet}NoNoThe wallet’s Gateway balance, balance_wei
POST /v1/chat/completionsYesYesA chat completion, charged to the key’s wallet
POST /v1/keys/challengeNoYesA message for the wallet to sign
POST /v1/keysNo: a signatureYesA new key, shown once
GET /v1/accountYesYesThe wallet’s balance, limits, keys, deposits and usage
DELETE /v1/keys/currentYesYesRevokes the key that sends it

The three key endpoints, with their requests and answers: Keys.

Chat completions

FieldRule
modelpro or flash (Models, below)
messagesA list of at least one message, as OpenAI’s
max_tokens or max_completion_tokensA positive whole number; above the tier’s maximum it is lowered to it; unset, the tier’s default
streamtrue for server-sent events
stream_options.include_usagetrue to receive the usage chunk at the end of a stream
n1 only
Other fieldsPassed to the host as sent, such as temperature

The answer is OpenAI’s chat completion object, and its model reads the tier’s id. A stream sends data: events and ends with data: [DONE]. When no event has come for 15 seconds, it sends a : keep-alive comment line, which clients skip.

Stream an answer
curl -N https://app.kyzen.network/v1/chat/completions \
  -H "Authorization: Bearer $KYZN_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"pro","stream":true,"messages":[{"role":"user","content":"Which stage binds?"}]}'

Account

GET /v1/account answers for the key’s wallet. Amounts are in wei of $KYZN, 18 decimals, as strings; times are milliseconds since 1970, UTC.

FieldHolds
walletThe key’s wallet, in lowercase
network, chain_idmainnet and 4663
deposit_addressThe Gateway contract, where top-ups go
balance_weiCredited minus charged
held_weiHeld for the wallet’s requests running now
available_weiThe balance less what is held
limitsrequests_per_minute 60, in_flight 4, keys 5
keysThe active keys: id, prefix, created
depositsThe latest 20 credits: txHash, amount, block, at
usageThe latest 50 charges: at, model, promptTokens, completionTokens, kyzn, estimated

Public reads

EndpointFieldHolds
/v1/statsliveTrue when the network has a recorded deployment and an inference host
/v1/statsrequests_servedEvery request the Gateway has charged
/v1/statsmodels_onlineTiers the host serves now, checked every five minutes
/v1/statsburned_last_24h_wei$KYZN burned by settlements confirmed in the last 24 hours
/v1/statskyzn_usdDollars per $KYZN at the median pool price, or null with no fresh price
/v1/postsdataPosts, newest first: id, kind, at, text
/v1/balance/{wallet}balance_weiCredited minus charged, for any wallet

#Models

The Gateway publishes its models by tier and names no model behind a tier. A request names the tier’s id, and the answer names it back.

TierModel id
Propro
Flashflash

GET /v1/models lists each tier in OpenAI’s model shape, with the Gateway’s own fields under kyzen. Each price is the host’s dollar rate plus the 10% margin.

FieldHolds
idThe id to send as model
nameThe tier’s name
object, created, owned_byOpenAI’s fields: model, 0, kyzen-network
kyzen.usd_per_million_input, kyzen.usd_per_million_outputDollars per million input or output tokens, as a decimal string
kyzen.kyzn_per_million_input, kyzen.kyzn_per_million_outputThe same in $KYZN at the median pool price of the last 15 minutes; null with no fresh price
kyzen.max_tokensThe most output tokens one request may ask for
List the models
curl https://app.kyzen.network/v1/models

#Errors

Errors take OpenAI’s shape, so OpenAI’s clients raise them as they raise OpenAI’s own. The status code and code name the case; message says what to do.

An error
{
  "error": {
    "message": "This wallet has made 60 requests in the last minute. Wait and retry.",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded",
    "param": null
  }
}
StatusCodeWhen
400invalid_requestThe body is not a JSON object, messages is empty, n is not 1, max_tokens is not a positive whole number, or kind is unknown
400invalid_walletThe address is not a 0x wallet address
400invalid_signatureThe nonce is missing, or the signature is not 0x hex
400challenge_expiredThe challenge is unknown, used, older than 10 minutes or another wallet’s
401invalid_api_keyThe key is missing, wrong or revoked
401invalid_signatureThe signature is not this wallet’s signature of the challenge
402insufficient_balanceThe most the request can cost does not fit in the balance not already held
403region_closedThe request comes from a closed country
403region_unconfirmedThe region cannot be confirmed; try again later
404model_not_foundThe model id is not a tier
404not_foundNo such route
409too_many_keysThe wallet already has 5 active keys; the challenge is used, so revoke a key, then ask for a new challenge
413request_too_largeThe body is over its limit
429rate_limit_exceeded60 chat completions from this wallet in the last minute
429too_many_in_flight4 chat completions from this wallet already running
500internal_errorAn unexpected error in the Gateway
502host_errorThe host did not answer in time or answered with an error; nothing is charged
503price_unavailableNo fresh $KYZN price; nothing is charged; try again shortly
503gateway_not_liveThe network has no recorded deployment or no inference host

The type follows the status: authentication_error for 401, permission_error for 403, rate_limit_error for 429, api_error for 500, 502 and 503, and invalid_request_error for the rest. A 429 carries retry-after, in seconds: until the oldest of the 60 chat completions leaves the minute, or 1 while 4 are running.

#Limits

Limits apply per wallet: every key of a wallet shares them. The request limits count chat completions; the other endpoints are not counted.

LimitValueBeyond it
Requests60 chat completions in any 60 seconds429 rate_limit_exceeded
At a time4 chat completions running429 too_many_in_flight
Keys5 active409 too_many_keys
Request body1,000,000 bytes; 10,000 for the key endpoints413 request_too_large
OutputThe tier’s max_tokensA larger request is lowered to it
Answer time120 secondsA stream ends there and is charged for what arrived; any other answer gets 502 host_error
Key challenge10 minutes, used once400 challenge_expired
BalanceThe most a request can cost, held before it runs402 insufficient_balance
Esc
  • OverviewGet started
  • Quick startGet started
  • Wallets and networkGet started
  • Where the app opensGet started
  • GuidesGuides
  • Buy $KYZNGuides