Run a completion via the gateway (API-key auth)
Proxies to the requested upstream provider (`openrouter`, `anthropic`, `engy`). Charges the caller's org for `provider cost × (1 + markup)` after a successful upstream response. Miner attribution resolves in order: `minerHotkey` in payload → API key's pinned miner → org's default miner → none.
/v1/gateway/completionsAuthorization
api-key Bearer sub41_live_…
In: header
Header Parameters
Optional client-chosen key (1–255 chars), scoped to the org. A repeat request with a key that already produced a successful completion is rejected with 409 and no provider call or debit occurs. Failed calls do not consume the key.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/v1/gateway/completions" \ -H "Content-Type: application/json" \ -d '{ "provider": "openrouter", "model": "anthropic/claude-3.5-sonnet", "messages": [ { "role": "system", "content": "Hello!" } ] }'{ "provider": "openrouter", "model": "anthropic/claude-3.5-sonnet", "output": "The market is likely to resolve YES because…", "usage": { "promptTokens": 412, "completionTokens": 187, "totalTokens": 599, "cacheReadInputTokens": 2048, "cacheCreationInputTokens": 0, "costUsd": 0.00342 }, "costMicro": "12500", "providerCostMicro": "10000", "markupBps": 2500, "balanceAfterMicro": "987500"}Overview
Every /v1 endpoint, generated from the live OpenAPI specification.
Run a completion via the gateway (validator auth) POST
Authenticated by a Bittensor validator's sr25519 signature over the newline-joined canonical message `sub41-gateway-v1\nMETHOD\npathAndQuery\nminerHotkey\nnonce\ntimestamp\nsha256(body) hex`. The body hash covers the request body exactly as sent on the wire (raw bytes) — send precisely the bytes you hashed; the server never re-serializes. The billed org is resolved from `x-miner-hotkey` via `OrgMiner` / `SubnetRegistration`. Replayed nonces and stale metagraph reads fail closed.