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 or images |
OPTIONS | CORS 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 namesubscription— active plan detailstoken_stats— usage, remaining tokens, usage by serviceapi_key_info— name, expiry, allowed providers/models, rate limitsavailable_providers— providers and chat-capable models, each with an estimatedpricingblockimage_generation_providers— providers and image models, each with an estimatedpricingblockpricing_meta— when the estimates above were last refreshedsupported_features—text_generation,image_generation
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 Toman cost before they spend tokens:
{
"id": "clx...",
"name": "GPT-5",
"capabilities": { "chat": true, "imageGeneration": false, "imageAnalysis": false, "streaming": false },
"maxTokens": 8000,
"pricing": {
"estimated_cost_toman": 6292,
"chat_cost_scenarios_toman": { "light": 1200, "typical": 6292, "heavy": 22370 },
"image_quality_costs_toman": null,
"price_tier": "expensive"
}
}
For chat models, chat_cost_scenarios_toman gives three sample costs (light = short message, typical, heavy = long context + max-length answer such as code) — a single number is misleading because cost scales with output length. Image models instead get image_quality_costs_toman (low / medium / high). price_tier (cheap | moderate | expensive) ranks the model relative to other active models of the same type.
These numbers are estimates, not exact bills — the exact amount depends on actual token usage and shifts with the exchange rate over time (see pricing_meta.rate_updated_at). The underlying dollar rate itself is not exposed. pricing is null when the platform’s pricing configuration is incomplete.
POST — generate content
Send a JSON body with at least:
| Field | Required | Description |
|---|---|---|
prompt | Yes | Text prompt for generation |
model | Yes | Model id or model name |
provider | No | Defaults to deepseek |
type | No | text (default) or image |
See Text Generation, Image Generation, and Parameters & Models for full details.