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.
| Detail | Rule |
|---|---|
| Base URL | https://app.kyzen.network/v1 |
| Key | Authorization: Bearer $KYZN_KEY, on the endpoints marked below; a key starts with kyzn_ |
| Request bodies | JSON, at most 1,000,000 bytes |
| Answers | JSON, never cached; a streamed answer as server-sent events |
| Charge | x-kyzen-charge: the request’s charge in $KYZN, on chat completions only, when the answer is not streamed |
| Browsers | Any 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 |
| Regions | The endpoints that act follow the app’s region rule (Where the app opens) |
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.
| Endpoint | Key | Region rule | Gives |
|---|---|---|---|
GET /v1/health | No | No | ok, the network, and live: whether the network has a recorded deployment |
GET /v1/models | No | No | The tiers, with their prices per million tokens |
GET /v1/stats | No | No | Requests served, models online, $KYZN burned in the last 24 hours, the $KYZN price |
GET /v1/posts | No | No | The latest 50 posts drafted from live data that pass the copy rules; ?kind=weekly, gateway or rotation for one kind |
GET /v1/balance/{wallet} | No | No | The wallet’s Gateway balance, balance_wei |
POST /v1/chat/completions | Yes | Yes | A chat completion, charged to the key’s wallet |
POST /v1/keys/challenge | No | Yes | A message for the wallet to sign |
POST /v1/keys | No: a signature | Yes | A new key, shown once |
GET /v1/account | Yes | Yes | The wallet’s balance, limits, keys, deposits and usage |
DELETE /v1/keys/current | Yes | Yes | Revokes the key that sends it |
The three key endpoints, with their requests and answers: Keys.
Chat completions
| Field | Rule |
|---|---|
model | pro or flash (Models, below) |
messages | A list of at least one message, as OpenAI’s |
max_tokens or max_completion_tokens | A positive whole number; above the tier’s maximum it is lowered to it; unset, the tier’s default |
stream | true for server-sent events |
stream_options.include_usage | true to receive the usage chunk at the end of a stream |
n | 1 only |
| Other fields | Passed 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.
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.
| Field | Holds |
|---|---|
wallet | The key’s wallet, in lowercase |
network, chain_id | mainnet and 4663 |
deposit_address | The Gateway contract, where top-ups go |
balance_wei | Credited minus charged |
held_wei | Held for the wallet’s requests running now |
available_wei | The balance less what is held |
limits | requests_per_minute 60, in_flight 4, keys 5 |
keys | The active keys: id, prefix, created |
deposits | The latest 20 credits: txHash, amount, block, at |
usage | The latest 50 charges: at, model, promptTokens, completionTokens, kyzn, estimated |
Public reads
| Endpoint | Field | Holds |
|---|---|---|
/v1/stats | live | True when the network has a recorded deployment and an inference host |
/v1/stats | requests_served | Every request the Gateway has charged |
/v1/stats | models_online | Tiers the host serves now, checked every five minutes |
/v1/stats | burned_last_24h_wei | $KYZN burned by settlements confirmed in the last 24 hours |
/v1/stats | kyzn_usd | Dollars per $KYZN at the median pool price, or null with no fresh price |
/v1/posts | data | Posts, newest first: id, kind, at, text |
/v1/balance/{wallet} | balance_wei | Credited 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.
| Tier | Model id |
|---|---|
| Pro | pro |
| Flash | flash |
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.
| Field | Holds |
|---|---|
id | The id to send as model |
name | The tier’s name |
object, created, owned_by | OpenAI’s fields: model, 0, kyzen-network |
kyzen.usd_per_million_input, kyzen.usd_per_million_output | Dollars per million input or output tokens, as a decimal string |
kyzen.kyzn_per_million_input, kyzen.kyzn_per_million_output | The same in $KYZN at the median pool price of the last 15 minutes; null with no fresh price |
kyzen.max_tokens | The most output tokens one request may ask for |
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.
{
"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
}
}| Status | Code | When |
|---|---|---|
| 400 | invalid_request | The 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 |
| 400 | invalid_wallet | The address is not a 0x wallet address |
| 400 | invalid_signature | The nonce is missing, or the signature is not 0x hex |
| 400 | challenge_expired | The challenge is unknown, used, older than 10 minutes or another wallet’s |
| 401 | invalid_api_key | The key is missing, wrong or revoked |
| 401 | invalid_signature | The signature is not this wallet’s signature of the challenge |
| 402 | insufficient_balance | The most the request can cost does not fit in the balance not already held |
| 403 | region_closed | The request comes from a closed country |
| 403 | region_unconfirmed | The region cannot be confirmed; try again later |
| 404 | model_not_found | The model id is not a tier |
| 404 | not_found | No such route |
| 409 | too_many_keys | The wallet already has 5 active keys; the challenge is used, so revoke a key, then ask for a new challenge |
| 413 | request_too_large | The body is over its limit |
| 429 | rate_limit_exceeded | 60 chat completions from this wallet in the last minute |
| 429 | too_many_in_flight | 4 chat completions from this wallet already running |
| 500 | internal_error | An unexpected error in the Gateway |
| 502 | host_error | The host did not answer in time or answered with an error; nothing is charged |
| 503 | price_unavailable | No fresh $KYZN price; nothing is charged; try again shortly |
| 503 | gateway_not_live | The 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.
| Limit | Value | Beyond it |
|---|---|---|
| Requests | 60 chat completions in any 60 seconds | 429 rate_limit_exceeded |
| At a time | 4 chat completions running | 429 too_many_in_flight |
| Keys | 5 active | 409 too_many_keys |
| Request body | 1,000,000 bytes; 10,000 for the key endpoints | 413 request_too_large |
| Output | The tier’s max_tokens | A larger request is lowered to it |
| Answer time | 120 seconds | A stream ends there and is charged for what arrived; any other answer gets 502 host_error |
| Key challenge | 10 minutes, used once | 400 challenge_expired |
| Balance | The most a request can cost, held before it runs | 402 insufficient_balance |