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
| Field | Type | Description |
|---|---|---|
object required | string | The kind of object returned, for example chat.completion. Always "key". |
id required | string | The answer's id. |
prefix required | string | |
scopes required | array of string | |
budgetEnvelopeId required | string or null | |
expiresAt required | string or null | |
createdAt required | string | |
lastUsedAt required | string or null | |
unit required | string | Always "mu". |
spendMu required | integer | micro-dollars, the unit of account |
period required | object | |
period.from required | string | |
period.to required | string |
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
401invalid_api_key403insufficient_scope429over 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"
}
}
}
}
}