API ReferenceFeatured

API Overview

Base URL, methods, CORS, and response conventions.

All documentation

The External AI API is a single endpoint that handles discovery (GET) and generation (POST).

Endpoint

https://abzar-ai.com/api/external/ai
MethodPurpose
GETReturn account info, providers, models, token stats, and key limits
POSTGenerate text or images
OPTIONSCORS preflight

CORS

By default, browser CORS is disabled. API keys are intended for server-side use only.

To allow specific browser origins (or all origins), set:

EXTERNAL_AI_CORS_ORIGINS=https://app.example.com,https://admin.example.com
# or
EXTERNAL_AI_CORS_ORIGINS=*

When enabled, responses include:

Access-Control-Allow-Origin: <matched-origin-or-*>
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization, X-API-Key

Never put pk_ API keys in frontend JavaScript.

Response convention

Successful responses:

{
  "success": true,
  "data": { }
}

Error responses:

{
  "success": false,
  "error": "Human-readable message",
  "details": { }
}

Always check success before reading data.

GET — discover capabilities

curl -X GET "https://abzar-ai.com/api/external/ai" \
  -H "X-API-Key: $ABZAR_AI_API_KEY"

The payload includes:

  • user — id, username, display name
  • subscription — active plan details
  • token_stats — usage, remaining tokens, usage by service
  • token_costs — current pricing configuration
  • api_key_info — name, expiry, allowed providers/models, rate limits
  • available_providers — providers and chat-capable models
  • image_generation_providers — providers and image models
  • supported_featurestext_generation, image_generation

Use this endpoint to build dynamic model pickers and to verify remaining quota before expensive jobs.

POST — generate content

Send a JSON body with at least:

FieldRequiredDescription
promptYesText prompt for generation
modelYesModel id or model name
providerNoDefaults to deepseek
typeNotext (default) or image

See Text Generation, Image Generation, and Parameters & Models for full details.