API ReferenceFeatured
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 servicetoken_costs— current pricing configurationapi_key_info— name, expiry, allowed providers/models, rate limitsavailable_providers— providers and chat-capable modelsimage_generation_providers— providers and image modelssupported_features—text_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:
| 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.