Login
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, images, or embeddings
OPTIONSCORS preflight (only when CORS is enabled)

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, X-Plugin-Slug, X-Kit-Version

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:

  • brand, dashboard_url, topup_url, docs_url — site identity helpers
  • user — id, username, display name
  • subscription — active plan details when present
  • token_stats — usage, remaining tokens, usage by service
  • api_key_info — name, expiry, allowed providers/models, rate limits
  • available_providers — models with stable creation times, effective limits, supported parameters, capabilities, and pricing estimates
  • image_generation_providers — image models with pricing estimates
  • embedding_providers — embedding models (when enabled)
  • pricing_meta — when estimates were last refreshed
  • supported_features — object flags including text_generation, chat_messages, image_generation, streaming, embedding, responses_api, tool_calling, structured_outputs, and token_management
  • supported_feature_list — same capabilities as a string array (handy for WordPress kits)
  • limitsmax_prompt_chars, max_completion_tokens, max_messages, max_embedding_inputs

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

Per-model pricing

Every model returned under available_providers[].models[] and image_generation_providers[].models[] includes a pricing object so you can show users an approximate cost before they spend tokens:

{
  "id": "clx...",
  "name": "GPT-5",
  "capabilities": {
    "chat": true,
    "imageGeneration": false,
    "imageAnalysis": false,
    "streaming": false,
    "embedding": false
  },
  "context_length": 128000,
  "max_output_tokens": 8192,
  "maxTokens": 8192,
  "pricing": {
    "estimated_cost_toman": 6292,
    "chat_cost_scenarios_toman": {
      "light": 1200,
      "typical": 6292,
      "heavy": 22370
    },
    "image_quality_costs_toman": null,
    "price_tier": "expensive"
  }
}

Field names end with _toman for historical reasons — they are platform credit units derived from the site ledger. Display currency on the customer UI may differ by site (IRR vs USD), but these estimate keys stay stable for clients.

For chat models, chat_cost_scenarios_toman gives three sample costs (light, typical, heavy). Image models instead get image_quality_costs_toman (low / medium / high). price_tier ranks the model relative to other active models of the same type.

These numbers are estimates, not exact bills. pricing is null when pricing configuration is incomplete.

POST — generate content

Send a JSON body with at least:

FieldRequiredDescription
modelYesModel id or model name from GET discovery
typeNotext (default), image, or embedding
prompt or messagesYes for textPrompt string, or chat messages[]
promptYes for imageImage description
inputYes for embeddingString or array of strings
providerNoMust match the model’s real provider when set
streamNotrue for SSE text streaming when the model supports it

Optional analytics headers (logged only): X-Plugin-Slug, X-Kit-Version.

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

For SDK-compatible response objects, use https://abzar-ai.com/v1 and see OpenAI Compatibility. Clients that require an OpenRouter-style path may use the equivalent https://abzar-ai.com/api/v1 alias.