Home / Docs / API reference

/v1/key

GET /v1/key

Authentication relay key (bearer)

Example request

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

r = requests.get(
    "https://api.massrelay.ai/v1/key",
    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/key", {
  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 "key".
id requiredstringThe answer's id.
prefix requiredstring
scopes requiredarray of string
budgetEnvelopeId requiredstring or null
expiresAt requiredstring or null
createdAt requiredstring
lastUsedAt requiredstring or null
unit requiredstring Always "mu".
spendMu requiredintegermicro-dollars, the unit of account
period requiredobject
period.from requiredstring
period.to requiredstring
Example response (shape)
{
  "object": "key",
  "id": "<id>",
  "prefix": "<prefix>",
  "scopes": [
    "<scopes>"
  ],
  "budgetEnvelopeId": "<budgetEnvelopeId>",
  "expiresAt": "<expiresAt>",
  "createdAt": "<createdAt>",
  "lastUsedAt": "<lastUsedAt>",
  "unit": "mu",
  "spendMu": 0,
  "period": {
    "from": "<from>",
    "to": "<to>"
  }
}

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

{
  "type": "object",
  "required": [
    "object",
    "id",
    "prefix",
    "scopes",
    "budgetEnvelopeId",
    "expiresAt",
    "createdAt",
    "lastUsedAt",
    "unit",
    "spendMu",
    "period"
  ],
  "properties": {
    "object": {
      "const": "key"
    },
    "id": {
      "type": "string"
    },
    "prefix": {
      "type": "string"
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "budgetEnvelopeId": {
      "type": [
        "string",
        "null"
      ]
    },
    "expiresAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string"
    },
    "lastUsedAt": {
      "type": [
        "string",
        "null"
      ]
    },
    "unit": {
      "const": "mu"
    },
    "spendMu": {
      "type": "integer",
      "description": "micro-dollars, the unit of account"
    },
    "period": {
      "type": "object",
      "required": [
        "from",
        "to"
      ],
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        }
      }
    }
  }
}