Skip to content

API reference ​

Base URL: https://api.infernear.dev

Inference routes live under /v1 and follow the OpenAI format. Key and account routes live at the root.

Authentication ​

Send your API key as a bearer token:

Authorization: Bearer inf_...

Keys are created by signing a message with your wallet. See API keys.

Inference routes ​

RouteKey neededPaid byWhat it does
GET /v1/modelsnoLists the served TEE chat models with their prices. Cached for 5 minutes
POST /v1/chat/completionsyesfree trial first, then creditsOpenAI Chat Completions, in standard or private mode
GET /v1/free-callsyesYour free trial status: {"per_user":5,"used":2,"remaining":3}
GET /v1/model/{model}noModel details, forwarded from NEAR AI unchanged
GET /v1/attestation/reportnoTEE attestation report, forwarded from NEAR AI unchanged
GET /v1/signature/{id}noThe model's signature for a completion, forwarded unchanged

POST /v1/chat/completions ​

The body is an OpenAI chat completion request.

FieldRule
modelAn exact id from GET /v1/models
messagesText messages. Tool definitions and tool calls are allowed
max_tokensAt most 4,096. Optional in standard mode (the relay fills it in); required in private mode
streamtrue for a streamed reply. In private mode, also send stream_options: {"include_usage": true}
nMust be 1 if present

Response headers ​

HeaderMeaning
Inference-IdThe id of this inference. A paid call is recorded on NEAR under it
X-InferNear-BillingHow this call is billed: free (a free trial call) or credits
X-InferNear-Free-RemainingOn free calls: trial calls left for this wallet

Browsers can read all three (they are listed in Access-Control-Expose-Headers).

Errors ​

Every error uses OpenAI's error shape:

json
{"error": {"message": "Bad, expired or revoked credentials", "type": "invalid_request_error", "code": "invalid_api_key"}}
StatusWhen
400Unsupported parameters, or an incomplete set of private-mode encryption headers
401 invalid_api_keyThe key is wrong or expired
401 revoked_api_keyThe key was revoked
402 insufficient_creditNo free trial calls left and not enough credit for this call
404The model is not one InferNear serves
413The request body is larger than 1 MiB
429More than 4 requests in flight for one user, or too many requests from one IP on the open routes
503 ledger_storage_lowThe credit ledger is short of storage; paid calls are paused until the operator tops it up
504The model did not start answering in time

Limits ​

LimitValue
Requests in flight per user4
Request body1 MiB
Reply cap (max_tokens)4,096
Open routes without a key (model details, attestation, signature, key and account routes)30 requests per minute per IP
API key lifetime30 days

Key routes ​

Most people create keys in the console. These are the routes it uses.

RouteBodyResponse
GET /auth/nonce{ "nonce" }: single use, valid for 5 minutes
POST /keysa wallet proof{ "key": "inf_...", "key_epoch", "expires_at", "account" }
POST /keys/revokea wallet proof{ "key_epoch", "tx_hash" }: ends every key that wallet issued

A wallet proof is one of:

  • EVM: { "message", "signature" }, where message is a Sign-In with Ethereum (EIP-4361) message for chain 8453 whose domain and URI are the console's origin, carrying the nonce and an expiration time.
  • NEAR: a near envelope with a NEP-413 signature from a full-access key of the account.

The message's statement names the action, and a proof signed for one action is refused for any other. The two key routes share one statement, Authorize one InferNear API key action., so a key proof is accepted by either of them.

The exact message formats are in docs/interfaces.md in the repository, and relay/scripts/live-check.mjs is a complete working example.

Account routes ​

These manage a handle and linked wallets. Each takes a wallet proof whose statement names the action. None sends a transaction. See Accounts and linked wallets.

RouteExtra body fieldStatement to signResult
POST /accounts/meSign in to InferNear.Your account, or null
POST /accountshandleCreate InferNear account "<handle>".The new account
POST /accounts/link/starthandleAdd a wallet to InferNear account "<handle>". (signed by a wallet already in the account)A one-use ticket, valid 10 minutes
POST /accounts/linkticketLink this wallet to InferNear account "<handle>". (signed by the wallet being added)The updated account
POST /accounts/unlinkhandleUnlink this wallet from InferNear account "<handle>". (signed by the wallet leaving)The updated account

Reading the ledger yourself ​

Balances and charges are public on NEAR. The credit ledger is the contract connector.infernear-ai.near, and these view methods need no key:

View methodArgumentsReturns
account{"user": "eip155:8453:<address, lower case>"} or {"user": "near:mainnet:<account id>"}credited, spent, available (micro-USD) and key_epoch
debited_amount{"inference_id": "<Inference-Id>"}The amount charged for that call, or null

Built at NEAR HACKATHON, 2026. Released under the MIT License.