Home / Docs / API reference

/v1/generation/{id}

GET /v1/generation/{id}

Authentication relay key (bearer)

Path parameters

id requiredstring

Example request

curl
curl https://api.massrelay.ai/v1/generation/{id} \
  -H "Authorization: Bearer $RELAY_KEY"
Python
import os, requests

r = requests.get(
    "https://api.massrelay.ai/v1/generation/{id}",
    headers={"Authorization": f"Bearer {os.environ['RELAY_KEY']}"},
)
r.raise_for_status()
print(r.json())
TypeScript
const r = await fetch("https://api.massrelay.ai/v1/generation/{id}", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.RELAY_KEY}` },
});
if (!r.ok) throw new Error(`${r.status} ${await r.text()}`);
console.log(await r.json());

Response

FieldTypeDescription
object requiredstringThe kind of object returned, for example chat.completion. Always "generation".
id requiredstringThe answer's id.
model requiredstring or nullThe model id. In a request it is optional: without it the key's routing chooses.
provider requiredstring or null
inputTokens requiredinteger
outputTokens requiredinteger
unit requiredstring Always "mu".
costMu requiredintegermicro-dollars, the unit of account
fee requiredobject or null
fee.costMuintegermicro-dollars, the unit of account
fee.planstring or null
fee.reasonstring or null
latencyMs requiredinteger or null
createdAt requiredstring or null
explain requiredstringthe /v1/route/explain/{id} path
Example response (shape)
{
  "object": "generation",
  "id": "<id>",
  "model": "provider/model-id",
  "provider": "<provider>",
  "inputTokens": 0,
  "outputTokens": 0,
  "unit": "mu",
  "costMu": 0,
  "fee": {
    "costMu": 0,
    "plan": "<plan>",
    "reason": "<reason>"
  },
  "latencyMs": "<latencyMs>",
  "createdAt": "<createdAt>",
  "explain": "<explain>"
}

Common errors

  • 401 invalid_api_key
  • 403 insufficient_scope
  • 429 over the request rate; read Retry-After

Every error has the same JSON shape; see Errors and Limits.

Full schema (JSON)

Response schema

{
  "description": "404 decision_not_found for another key's, another workspace's or a missing id.",
  "type": "object",
  "required": [
    "object",
    "id",
    "model",
    "provider",
    "inputTokens",
    "outputTokens",
    "unit",
    "costMu",
    "fee",
    "latencyMs",
    "createdAt",
    "explain"
  ],
  "properties": {
    "object": {
      "const": "generation"
    },
    "id": {
      "type": "string"
    },
    "model": {
      "type": [
        "string",
        "null"
      ]
    },
    "provider": {
      "type": [
        "string",
        "null"
      ]
    },
    "inputTokens": {
      "type": "integer"
    },
    "outputTokens": {
      "type": "integer"
    },
    "unit": {
      "const": "mu"
    },
    "costMu": {
      "type": "integer",
      "description": "micro-dollars, the unit of account"
    },
    "fee": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "costMu": {
          "type": "integer",
          "description": "micro-dollars, the unit of account"
        },
        "plan": {
          "type": [
            "string",
            "null"
          ]
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "latencyMs": {
      "type": [
        "integer",
        "null"
      ]
    },
    "createdAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "explain": {
      "type": "string",
      "description": "the /v1/route/explain/{id} path"
    }
  }
}