AlmanacDocs
API referenceGateway

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.

POST/v1/gateway/completions
Authorization<token>

Bearer sub41_live_…

In: header

Header Parameters

Idempotency-Key?string

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"}