GuidesFeatured
Code Examples
cURL, JavaScript, Python, and PHP integration samples.
Copy-paste samples for the most common languages. Replace your-api-key-here with a real key from Dashboard → Settings → API Keys.
Always take
modelnames fromGET https://abzar-ai.com/api/external/ai. The examples below useabzar-ai/openai/gpt-image-1-minias common placeholders.
OpenAI SDK (recommended)
import OpenAI from "openai"
const client = new OpenAI({
apiKey: process.env.ABZAR_AI_API_KEY,
baseURL: "https://abzar-ai.com/v1"
})
const response = await client.responses.create({
model: "your-chat-model",
input: "Write a warm, concise product welcome."
})
console.log(response.output_text)
For Python, construct OpenAI(api_key=..., base_url="https://abzar-ai.com/v1") and
use the same responses, chat.completions, embeddings, and images resources.
See OpenAI Compatibility for capability boundaries.
cURL
Text generation
curl -X POST "https://abzar-ai.com/api/external/ai" \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Write a product description for wireless headphones",
"model": "abzar-ai",
"provider": "deepseek",
"type": "text",
"max_tokens": 500,
"temperature": 0.7
}'
Chat messages + streaming
curl -N -X POST "https://abzar-ai.com/api/external/ai" \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"type": "text",
"model": "abzar-ai",
"stream": true,
"messages": [
{ "role": "user", "content": "Say hello in one sentence." }
]
}'
Image generation
curl -X POST "https://abzar-ai.com/api/external/ai" \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Minimal product photo of wireless headphones on white background",
"model": "openai/gpt-image-1-mini",
"provider": "openai",
"type": "image",
"size": "1024x1024",
"quality": "high",
"style": "natural"
}'
Embeddings
curl -X POST "https://abzar-ai.com/api/external/ai" \
-H "X-API-Key: your-api-key-here" \
-H "Content-Type: application/json" \
-d '{
"type": "embedding",
"model": "text-embedding-3-small",
"input": ["first doc", "second doc"]
}'
JavaScript (Node / server)
const API_URL = "https://abzar-ai.com/api/external/ai"
const API_KEY = process.env.ABZAR_AI_API_KEY
async function generateText(prompt) {
const response = await fetch(API_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
body: JSON.stringify({
prompt,
model: "abzar-ai",
provider: "deepseek",
type: "text",
max_tokens: 1000,
temperature: 0.7
})
})
const result = await response.json()
if (!result.success) {
throw new Error(result.error || "Generation failed")
}
return result.data.content
}
async function generateImage(prompt) {
const response = await fetch(API_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY
},
body: JSON.stringify({
prompt,
model: "openai/gpt-image-1-mini",
provider: "openai",
type: "image",
size: "1024x1024",
quality: "medium",
style: "vivid"
})
})
const result = await response.json()
if (!result.success) {
throw new Error(result.error || "Image generation failed")
}
return result.data.image_url
}
Python
import os
import requests
API_URL = "https://abzar-ai.com/api/external/ai"
API_KEY = os.environ["ABZAR_AI_API_KEY"]
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json",
}
def generate_text(prompt: str) -> str:
payload = {
"prompt": prompt,
"model": "abzar-ai",
"provider": "deepseek",
"type": "text",
"max_tokens": 1000,
"temperature": 0.7,
}
response = requests.post(API_URL, json=payload, headers=headers, timeout=60)
data = response.json()
if not data.get("success"):
raise RuntimeError(data.get("error", "Generation failed"))
return data["data"]["content"]
def generate_image(prompt: str) -> str:
payload = {
"prompt": prompt,
"model": "openai/gpt-image-1-mini",
"provider": "openai",
"type": "image",
"size": "1024x1024",
"quality": "high",
"style": "natural",
}
response = requests.post(API_URL, json=payload, headers=headers, timeout=120)
data = response.json()
if not data.get("success"):
raise RuntimeError(data.get("error", "Image generation failed"))
return data["data"]["image_url"]
PHP
<?php
function call_external_ai(string $prompt, string $api_key, array $options = []): array {
$payload = array_merge([
'type' => 'text',
'model' => 'abzar-ai',
'provider' => 'deepseek',
'max_tokens' => 1000,
'temperature' => 0.7,
'prompt' => $prompt,
], $options);
$ch = curl_init('https://abzar-ai.com/api/external/ai');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: ' . $api_key,
],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_TIMEOUT => 60,
]);
$body = curl_exec($ch);
if ($body === false) {
throw new RuntimeException(curl_error($ch));
}
curl_close($ch);
$data = json_decode($body, true);
if (!($data['success'] ?? false)) {
throw new RuntimeException($data['error'] ?? 'Request failed');
}
return $data['data'];
}
// Text
$text = call_external_ai('Write a short product blurb', getenv('ABZAR_AI_API_KEY'));
// Image
$image = call_external_ai(
'Studio photo of a ceramic mug',
getenv('ABZAR_AI_API_KEY'),
[
'type' => 'image',
'model' => 'openai/gpt-image-1-mini',
'provider' => 'openai',
'size' => '1024x1024',
'quality' => 'high',
'style' => 'natural',
]
);
WordPress helper
function call_external_ai($prompt, $api_key, $options = []) {
$options = array_merge([
'type' => 'text',
'model' => 'abzar-ai',
'provider' => 'deepseek',
'max_tokens' => 1000,
'temperature' => 0.7,
'prompt' => $prompt,
], $options);
$response = wp_remote_post('https://abzar-ai.com/api/external/ai', [
'headers' => [
'X-API-Key' => $api_key,
'Content-Type' => 'application/json',
],
'body' => wp_json_encode($options),
'timeout' => 60,
]);
if (is_wp_error($response)) {
return ['success' => false, 'error' => $response->get_error_message()];
}
return json_decode(wp_remote_retrieve_body($response), true);
}
Next steps
- Review Errors & Rate Limits
- Discover live models with API Overview
- Download the full documentation from the docs home page