BETA

Reference

Limits, headers and error codes shared by every product.

Usage & Limits

Read-only endpoints to inspect your key, your usage and your balance. They are authenticated with your API key (any scope), keep working when your balance is used up, and do not count against your rate limit.

GET /v1/me

Returns the authenticating key's metadata and the owner's email.

curl https://alapi.deep.sa/v1/me -H "Authorization: Bearer sk-alapi-..."

{
  "key": {
    "name": "Production",
    "prefix": "sk-alapi-abc",
    "scopes": ["models", "alembedding"],
    "expires_at": null,
    "rate_limit_per_minute": 60,
    "daily_request_limit": null,
    "created_at": "2026-01-01T00:00:00Z",
    "last_used_at": "2026-01-02T12:00:00Z"
  },
  "email": "you@example.com"
}
GET /v1/me/usage

Returns per-day, per-key, per-model usage for a date range.

Query parameters: start and end (YYYY-MM-DD, default the last 30 days), granularity=day. The range must not exceed 90 days.

curl "https://alapi.deep.sa/v1/me/usage?start=2026-01-01&end=2026-01-31" \
  -H "Authorization: Bearer sk-alapi-..."

{
  "start": "2026-01-01",
  "end": "2026-01-31",
  "granularity": "day",
  "data": [
    { "date": "2026-01-01", "key_prefix": "sk-alapi-abc", "model": "allam-7b",
      "requests": 12, "tokens_prompt": 800, "tokens_completion": 1500, "failed": 0, "wallet_sar": 0 },
    { "date": "2026-01-01", "key_prefix": "sk-alapi-abc", "model": "google/gemini-3.8-flash",
      "requests": 2, "tokens_prompt": 3000, "tokens_completion": 1000, "failed": 0, "wallet_sar": 0.0162 }
  ]
}
GET /v1/me/balance

Returns what pays for your calls, in the order it is used: the requests you bought before plans (any model) and old alOCR pages, then your plan's usage, then your wallet. A team member sees the team's shared balance.

curl https://alapi.deep.sa/v1/me/balance -H "Authorization: Bearer sk-alapi-..."

{
  "legacy": {
    "requests": { "balance": 500, "used": 120, "remaining": 380 },
    "ocr_pages": { "balance": 300, "used": 50, "remaining": 250 }
  },
  "plan": {
    "name": "Starter", "period_end": "2026-11-13T09:00:00Z", "trial_ends_at": null,
    "auto_renews": true, "cancelled_at": null, "requests_at_once": 1, "requests_per_minute": 60,
    "usage": {
      "month": { "used_percent": 3, "resets_at": "2026-11-13T09:00:00Z" }
    }
  },
  "wallet": { "currency": "SAR", "balance": 42.5 },
  "team": null
}

Plan usage is shown as a percentage of the month's limit, with the time it resets. usage is null on a plan without a usage limit, and plan is null without a plan. wallet.balance is in SAR before VAT.

GET /v1/me/credits Deprecated

Use /v1/me/balance. This endpoint returns your old prepaid balance only and will be removed. Responses carry Deprecation and Link headers.

Returns your old prepaid request and OCR page balances.

curl https://alapi.deep.sa/v1/me/credits -H "Authorization: Bearer sk-alapi-..."

{
  "requests": { "balance": 500, "used": 120, "remaining": 380 },
  "ocr_pages": { "balance": 300, "used": 50, "remaining": 250 },
  "team": null
}

The team object is null unless you are an active member of a team.

wallet_sar in /v1/me/usage is what the calls took from your wallet, in SAR.

Billing and automatic renewal

A plan is paid a month at a time. When you pay with “Save this card for automatic renewal” ticked, the card is saved once the payment is confirmed and the plan renews itself at the end of each month: we email you three days before with the amount and the last four digits of the card. If the card is declined we try again on each of the next two days, and the plan stays usable meanwhile; after the third decline the plan ends and calls are paid from your wallet. Without a saved card, renew by hand from the dashboard.

To change plan, choose “Switch at renewal” on the pricing page or the dashboard: the new plan starts when the current month ends and nothing is charged before then. Undo the change from the dashboard at any time before that date.

We never see or store your card number: the card is entered in our payment provider's form and we keep only its reference. To remove the card, open the dashboard's Payment method card and choose Remove card; automatic renewal turns off and the reference is deleted at the provider.

Rate limits & expiry

Keys may carry a per-minute and a daily request limit. When exceeded, requests return 429 with these headers:

HTTP/1.1 429 Too Many Requests
Retry-After: 42
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1893456000

{ "error": { "message": "Rate limit exceeded...", "type": "rate_limit_error" } }

A key past its expiry returns 401 with the api_key_expired code:

HTTP/1.1 401 Unauthorized

{ "error": { "message": "API key expired", "type": "auth_error", "code": "api_key_expired" } }

CSV export

Signed-in users can download their request logs as CSV from the Usage and Dashboard pages (GET /logs/export?start=&end=).

Error Handling

The API uses standard HTTP status codes to indicate success or failure of requests.

Error Response Format:

error.json
{
  "error": {
    "message": "Error description",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}
400 Bad Request - Invalid request parameters
401 Unauthorized - Missing or invalid API key
403 Forbidden - API key lacks required permissions
404 Not Found - Resource doesn't exist
429 Too Many Requests - Rate limit exceeded
500 Internal Server Error - Server-side error
400 model_type_mismatch · A chat model was sent to embeddings, or an embedding model to chat.
400 tools_not_supported · The request has tools but the model does not support them.
404 model_not_found · The model name does not exist. The message suggests the closest name; see GET /v1/models.
410 model_retired · The model was retired and its name no longer works. The message names the replacement.
503 model_unavailable · The model is temporarily unavailable. Retry shortly.
402 insufficient_balance · Nothing left to pay for the call: your old balance is used up and you have no plan or wallet balance. "Your balance is used up. Subscribe to a plan or top up your wallet at /pricing."
402 usage_limit_exceeded · Your plan's monthly usage is used up and your wallet is empty. The message says when the usage resets, for example: "This month's usage is used up. It resets on 2026-11-13. Top up your wallet or upgrade your plan at /pricing to keep going."
429 concurrency_limit_exceeded · More requests at once than your plan allows: "Too many requests at once for your plan (limit N). Retry shortly." Retry after the Retry-After header.

Retired model names

When a model is retired, its old name keeps working until a sunset date and is served by its replacement. Those responses carry the headers below, so you can find and update the calls before the name answers 410 model_retired.

response headers
Deprecation: @1791277200
Sunset: Fri, 04 Dec 2026 21:00:00 GMT
Link: </models/qwen/qwen3.8-27b>; rel="successor-version"
X-Alapi-Warning: qwen/qwen3.6-27b is retired. Requests are served by qwen/qwen3.8-27b until 2026-12-05; update your model name.

Ready to Get Started?

Generate an API key from your dashboard and start building

Activate account?

Activate this account?