API Overview
Base URL, methods, CORS, and response conventions.
The External AI API is a single endpoint that handles discovery (GET) and generation (POST).
Endpoint
https://abzar-ai.com/api/external/ai
| Method | Purpose |
|---|---|
GET | Return account info, providers, models, token stats, and key limits |
POST | Generate text, images, or embeddings |
OPTIONS | CORS 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 helpersuser— id, username, display namesubscription— active plan details when presenttoken_stats— usage, remaining tokens, usage by serviceapi_key_info— name, expiry, allowed providers/models, rate limitsavailable_providers— models with stable creation times, effective limits, supported parameters, capabilities, andpricingestimatesimage_generation_providers— image models withpricingestimatesembedding_providers— embedding models (when enabled)pricing_meta— when estimates were last refreshedsupported_features— object flags includingtext_generation,chat_messages,image_generation,streaming,embedding,responses_api,tool_calling,structured_outputs, andtoken_managementsupported_feature_list— same capabilities as a string array (handy for WordPress kits)limits—max_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:
| Field | Required | Description |
|---|---|---|
model | Yes | Model id or model name from GET discovery |
type | No | text (default), image, or embedding |
prompt or messages | Yes for text | Prompt string, or chat messages[] |
prompt | Yes for image | Image description |
input | Yes for embedding | String or array of strings |
provider | No | Must match the model’s real provider when set |
stream | No | true 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.