Skip to main content

Personal Management API

The Personal Management API is designed for scripts, internal dashboards, and automation. Its first version supports balance lookup, available groups, API key CRUD, and per-key usage details, summaries, and daily trends.

Create a management key​

Sign in to MuskAI, open API Keys, and create a key in the “Personal Management API” card.

The key starts with sk-mgmt- and is shown in full only once. MuskAI stores only its hash.

:::warning Privileged credential This key can view your balance and manage every API key in your account. Never put it in Claude Code, Codex, Cherry Studio, or another model client. Normal inference API keys cannot call management endpoints. :::

Base URL and authentication​

BASE_URL="https://muskapi.cc/api/v1/management"
MANAGEMENT_KEY="sk-mgmt-..."
Authorization: Bearer sk-mgmt-...
Content-Type: application/json

Successful responses use { "code": 0, "message": "success", "data": ... }.

Endpoints​

MethodPathPurpose
GET/balanceRead account balances
GET/groups/availableList groups the user may bind
GET/groups/ratesRead user-specific group rates
GET/api-keysList API keys
POST/api-keysCreate API keys
GET/api-keys/{id}Read one key
PUT/api-keys/{id}Update one key
DELETE/api-keys/{id}Delete one key
GET/api-keys/{id}/usageRequest-level usage records
GET/api-keys/{id}/usage/statsAggregated usage
GET/api-keys/{id}/usage/dailyDaily usage trend

Examples​

Read balances:

curl "$BASE_URL/balance" -H "Authorization: Bearer $MANAGEMENT_KEY"

List keys:

curl "$BASE_URL/api-keys?page=1&page_size=20&status=active" \
-H "Authorization: Bearer $MANAGEMENT_KEY"

List parameters include page, page_size, search, status, and group_id.

Create a key:

curl -X POST "$BASE_URL/api-keys" \
-H "Authorization: Bearer $MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"production-bot","group_id":12,"quota":20,"rate_limit_1d":5,"expires_in_days":90}'

Create fields include name, group_id, group_bindings, cross_group_retry_enabled, custom_key, count, quota, rate_limit_5h, rate_limit_1d, rate_limit_7d, expires_in_days, ip_whitelist, ip_blacklist, openai_reasoning_summary_disabled, and openai_degraded_retry_enabled.

Update a key:

curl -X PUT "$BASE_URL/api-keys/123" \
-H "Authorization: Bearer $MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"production-bot-v2","status":"active","quota":50,"expires_at":"2026-12-31T23:59:59Z"}'

Updates also support reset_quota: true and reset_rate_limit_usage: true. Omitted fields stay unchanged. Do not send an empty group_bindings array when you mean “leave bindings unchanged.”

Query request-level usage:

curl "$BASE_URL/api-keys/123/usage?page=1&page_size=50&start_date=2026-08-01&end_date=2026-08-11&timezone=Asia%2FShanghai" \
-H "Authorization: Bearer $MANAGEMENT_KEY"

Optional filters include model, request_type, billing_type, start_date, end_date, timezone, and exact_total.

Query aggregates or daily usage:

curl "$BASE_URL/api-keys/123/usage/stats?period=month" \
-H "Authorization: Bearer $MANAGEMENT_KEY"

curl "$BASE_URL/api-keys/123/usage/daily?days=30&timezone=Asia%2FShanghai" \
-H "Authorization: Bearer $MANAGEMENT_KEY"

MuskAI verifies that every {id} belongs to the user associated with the management key.

Rotation and revocation​

Regenerate or revoke the key from API Keys → Personal Management API. Rotation invalidates the old key immediately. Store the key in a secret manager or environment variable and never commit it to Git.