Platform API: integration and authentication
The Platform API lets other products manage organization sub-users, issue short-lived standalone page links, and retrieve balances, usage records, and recharge history. Its /api/v1 prefix lives on the platform website origin. Model inference uses a separate gateway /v1 Base URL.
Integration sequence
- Create an organization in the console and keep its
sk-org-…admin key on your backend. - Configure the organization's allowed models and multipliers.
- Create a sub-user with your product's stable
external_id; save the returned user ID and invocation key (sk-io-…). - Call
POST /api/v1/org/access-linkswith the organization admin key to issue a 30-minute UUID link for recharging, viewing recharge history, or viewing usage statements. - Hand the generated URL directly to the end user—no login required and no raw API key exposed in the URL.
Request origin
PLATFORM_ORIGIN in examples means the current deployment's website origin, without /v1 or /api/v1. Do not substitute the model gateway domain. Each site uses its own deployment origin and account currency. Amounts are never converted or combined across currencies.
curl "$PLATFORM_ORIGIN/api/v1/org/users?external_id=uid_10001" \
-H "Authorization: Bearer $ORG_ADMIN_KEY"
Credentials and permissions
| Credential | Purpose | Accepted by standalone user pages |
|---|---|---|
Organization admin key sk-org-… | Manage users, model policies, usage, earnings, and issue scoped UUID links | No |
Sub-user API key sk-io-… | Call allowed models; passed in the request body when issuing a UUID link | No |
| Scoped page UUID (30-min TTL) | Strictly 1-to-1 access to one standalone page (usage, recharges, or recharge) | Yes |
| Project keys, personal keys, session cookies | Their respective product permissions; no organization sub-user identity | No |
API authentication uses Authorization: Bearer <credential> and requires no browser session. Keep admin credentials away from end users.
Model access
All sub-users share the organization's model allowlist. Unconfigured or removed models are absent from /v1/models; direct calls return HTTP 403 MODEL_NOT_ALLOWED (a model without an available mapping may return 404 first). An empty organization allowlist permits no models. Key rules may only narrow these permissions.
Endpoint index
Sub-users call the model gateway with their own API key. Generation requests with a zero sub-user balance return 402 ORG_USER_INSUFFICIENT_BALANCE; the organization creator's personal wallet is not used. Requests and earnings appear in organization reporting, outside personal request logs. Sub-user balances and personal wallets are separate.
| Method and path | Authentication | Purpose |
|---|---|---|
GET /api/v1/org | Organization admin key | Retrieve the organization |
PATCH /api/v1/org | Organization admin key | Update its name/default multiplier |
GET /api/v1/org/models | Organization admin key | Retrieve model policies |
PUT /api/v1/org/models | Organization admin key | Set allowed models and multipliers |
POST /api/v1/org/users | Organization admin key | Create a sub-user |
GET /api/v1/org/users | Organization admin key | List sub-users |
GET /api/v1/org/users/{userId} | Organization admin key | Retrieve a user and key metadata |
PATCH /api/v1/org/users/{userId} | Organization admin key | Update name, external ID or metadata |
POST /api/v1/org/users/{userId}/recharge-order | Organization admin key | Create a recharge order |
GET /api/v1/org/usage | Organization admin key | Retrieve organization usage |
GET /api/v1/org/earnings | Organization admin key | Retrieve organization earnings |
POST /api/v1/org/access-links | Organization admin key | Issue a 30-minute scoped UUID page link |
GET /api/v1/me/statement | usage UUID | Read balance and usage charges |
GET /api/v1/me/recharges | recharges UUID | Read balance and credited recharge history |
GET /api/v1/me/recharge-portal | recharge UUID | Read balance and currency for the recharge page |
POST /api/v1/me/recharge-portal | recharge UUID | Create a recharge order from the standalone page |
GET /api/v1/me/recharge-portal/{orderId} | recharge UUID | Poll order status on the standalone recharge page |
Errors and retries
Errors have the shape {"error":"CODE"}. Common statuses are 400 (invalid input), 401 (invalid or expired credential), 404 (resource absent or outside this organization), and 409 (duplicate organization-scoped name or external ID).
User creation has no idempotency-key support. If a response is uncertain, query by the stable external_id before retrying. Credential, balance, recharge, and statement responses are not cached.