Gemini 2.5 Flash Preview - يدعم المدخلات والمخرجات المتعددة
OpenAI GPT-4.1 mini - نموذج نصي متقدم
Qwen 2.5 Coder 32B - متخصص في البرمجة
| المعامل | النوع | الضروري | الوصف |
|---|---|---|---|
| model | string | ✓ | "gemini" |
| messages | array | ✓ | مصفوفة الرسائل |
| media_attachments | array | مرفقات الوسائط (صور، صوت) |
{
"model": "gemini",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "ما الذي تراه في هذه الصورة؟"
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA...."
}
}
]
}
]
}
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gemini",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "أرى في الصورة منظر طبيعي جميل مع جبال خضراء...",
"audio": "UklGRnoGAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQoGAACBhYqF..."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
async function callGeminiAPI(prompt, mediaAttachments = []) {
const response = await fetch('https://text.pollinations.ai/openai', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'gemini',
messages: [
{
role: 'user',
content: [
{
type: 'text',
text: prompt
},
...mediaAttachments.map(media => ({
type: media.type === 'image' ? 'image_url' : 'audio_url',
[media.type === 'image' ? 'image_url' : 'audio_url']: {
url: media.data
}
}))
]
}
]
})
});
const data = await response.json();
return data.choices[0].message.content;
}
// مثال للاستخدام
const result = await callGeminiAPI('ما الذي تراه في هذه الصورة؟', [
{
type: 'image',
data: 'data:image/jpeg;base64,...'
}
]);
| المعامل | النوع | الضروري | الوصف |
|---|---|---|---|
| prompt | string | ✓ | وصف الصورة المطلوبة |
| model | string | نموذج الصور (flux, turbo, etc.) | |
| width | number | عرض الصورة | |
| height | number | ارتفاع الصورة |
// توليد صورة بسيطة https://image.pollinations.ai/prompt/منظر%20طبيعي%20جميل // مع معاملات إضافية https://image.pollinations.ai/prompt/قطة%20لطيفة?model=flux&width=512&height=512
| المعامل | النوع | الضروري | الوصف |
|---|---|---|---|
| prompt | string | ✓ | النص المراد تحويله إلى كلام |
| model | string | ✓ | "openai-audio" |
| voice | string | نوع الصوت (alloy, echo, etc.) |
// تحويل نص إلى كلام https://text.pollinations.ai/مرحبا%20بكم?model=openai-audio&voice=alloy // استخدام في JavaScript const audioUrl = 'https://text.pollinations.ai/هذا%20نص%20تجريبي?model=openai-audio'; const audio = new Audio(audioUrl); audio.play();
لا حاجة لبطاقات ائتمان أو اشتراكات، خدمة مجانية 100%
استخدم الخدمة مباشرة بدون مصادقة أو مفاتيح وصول
بنية تحتية قوية تضمن استجابة سريعة ووقت تشغيل عالي
لا يتم تخزين أي بيانات للمستخدمين، تصميم يركز على الخصوصية
// مثال شامل لاستخدام Gemini API في JavaScript
class PollinationsAPI {
constructor() {
this.baseURL = 'https://text.pollinations.ai/openai';
}
// إرسال رسالة نصية
async sendTextMessage(model, message) {
const response = await fetch(this.baseURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: model,
messages: [{ role: 'user', content: message }]
})
});
return await response.json();
}
// إرسال رسالة مع وسائط (لـ Gemini)
async sendMediaMessage(prompt, mediaFiles) {
const mediaAttachments = await Promise.all(
mediaFiles.map(async (file) => {
const base64 = await this.fileToBase64(file);
return {
type: file.type.startsWith('image/') ? 'image' : 'audio',
data: base64,
name: file.name,
mime_type: file.type
};
})
);
const response = await fetch(this.baseURL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'gemini',
messages: [{ role: 'user', content: prompt }],
media_attachments: mediaAttachments
})
});
return await response.json();
}
// تحويل الملف إلى Base64
fileToBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
// توليد صور
generateImage(prompt, options = {}) {
const params = new URLSearchParams({
model: options.model || 'flux',
width: options.width || 512,
height: options.height || 512
});
return `https://image.pollinations.ai/prompt/${encodeURIComponent(prompt)}?${params}`;
}
}
// استخدام الفئة
const api = new PollinationsAPI();
// مثال للاستخدام
const textResponse = await api.sendTextMessage('gemini', 'مرحبا، كيف حالك؟');
console.log(textResponse.choices[0].message.content);
// مثال للوسائط
const imageFile = document.getElementById('imageInput').files[0];
const mediaResponse = await api.sendMediaMessage('ما الذي تراه في هذه الصورة؟', [imageFile]);