Yapay zeka sohbet platformumuzun REST API'si ile uygulamalarınızı entegre edin. Çoklu model desteği, streaming yanıtlar ve kullanım takibi.
Bearer token tabanlı kimlik doğrulama, CSRF korumasıyla güvenli erişim.
Streaming desteği ile gerçek zamanlı yanıtlar. SSE protokolü ile anında veri akışı.
Paket bazlı rate limiting, token/mesaj limitleri ve kullanım takibi.
Tüm API istekleri için oturum açmış olmanız gerekmektedir. API isteklerinde session cookie veya X-Session-Token header'ı kullanılır.
API endpointlerine erişim için önce /giris sayfasından oturum açın. Session cookie'niz otomatik olarak gönderilecektir. API kullanımı paketinize tabidir.
// Her istekte gonderilmesi gereken header'lar: Content-Type: application/json Accept: application/json X-Requested-With: XMLHttpRequest
AI modelleriyle sohbet başlatın ve mesaj gönderin.
AI modeline mesaj gönderir ve yanıt alır. Streaming desteği vardır.
POST /api/chat| Parametre | Tip | Zorunlu | Aciklama |
|---|---|---|---|
| message | string | Evet | Kullanıcı mesajı |
| conversation_id | integer | Hayir | Sohbet ID (boş ise yeni sohbet oluşturulur) |
| model_id | integer | Hayir | Model ID (boş ise varsayılan model kullanılır) |
| system_prompt_id | integer | Hayir | Sistem komutu ID |
{"content": "Merhaba! Size nasil yardimci olabilirim?", "conversation_id": 42, "model": "GPT-4o"}{"error": "Gunluk mesaj limitinize ulastiniz (50). Yarin tekrar deneyin veya paketinizi yuksteltin.", "type": "limit_exceeded", "upgrade_url": "/paketler"}$ch = curl_init('https://ekagpt.ekasunucu.org/api/chat');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'message' => 'Merhaba, nasilsin?',
'model_id' => 1
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Cookie: PHPSESSID=' . session_id()
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);const response = await fetch('https://ekagpt.ekasunucu.org/api/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({
message: 'Merhaba, nasilsin?',
model_id: 1
})
});
const data = await response.json();import requests
response = requests.post(
'https://ekagpt.ekasunucu.org/api/chat',
json={
'message': 'Merhaba, nasilsin?',
'model_id': 1
},
cookies={'PHPSESSID': 'your_session_id'}
)
data = response.json()Sohbet gecmisini yonetin.
Kullanicinin tum sohbetlerini grouped (pinned, today, yesterday, vb.) olarak dondurur.
GET /api/conversations{"conversations": {"pinned": [], "today": [{"id": 1, "title": "Yeni Sohbet", "message_count": 5, "updated_at": "2026-03-28 00: 00: 00"}], "yesterday": [], "last_7_days": [], "last_30_days": [], "older": []}}Bos bir sohbet olusturur.
POST /api/conversations| Parametre | Tip | Zorunlu | Aciklama |
|---|---|---|---|
| title | string | Hayir | Sohbet basligi (varsayilan: "Yeni Sohbet") |
| model_id | integer | Hayir | Kullanilacak model ID |
| system_prompt_id | integer | Hayir | Sistem komutu ID |
{"conversation": {"id": 42, "title": "Yeni Sohbet", "model_id": 1, "created_at": "2026-03-28 00: 00: 00"}}Belirtilen sohbetin mesajlariyla birlikte detayini dondurur.
GET /api/conversations/{id}{"conversation": {"id": 42, "title": "AI Sohbet"}, "messages": [{"id": 1, "role": "user", "content": "Merhaba"}, {"id": 2, "role": "assistant", "content": "Merhaba! Size nasil yardimci olabilirim?"}]}{"error": "Sohbet bulunamadi"}Sohbet basligini, sabitleme durumunu veya modelini gunceller.
PUT /api/conversations/{id}| Parametre | Tip | Zorunlu | Aciklama |
|---|---|---|---|
| title | string | Hayir | Yeni baslik |
| is_pinned | integer | Hayir | 1: Sabitle, 0: Kaldir |
| model_id | integer | Hayir | Yeni model ID |
{"success": true}Belirtilen sohbeti ve tum mesajlarini siler.
DELETE /api/conversations/{id}{"success": true}Kullanicinin tum sohbet gecmisini temizler.
POST /api/conversations/clear{"success": true}Mevcut AI modellerini listeleyin.
Sistemdeki tum aktif AI modellerini listeler.
GET /api/models{"models": [{"id": 1, "display_name": "GPT-4o", "model_id": "gpt-4o", "provider_id": 1, "supports_streaming": true, "is_free": false, "context_length": 128000}]}Hesabinizin kullanim istatistiklerini goruntuleyin.
Gunluk ve aylik mesaj/token kullanim istatistiklerini dondurur.
GET /api/usage{"usage": {"daily_messages": 15, "daily_tokens": 12500, "monthly_messages": 250, "monthly_tokens": 180000, "daily_message_limit": 50, "monthly_message_limit": 0, "daily_token_limit": 100000, "monthly_token_limit": 0, "daily_message_pct": 30, "monthly_message_pct": 0}}Aktif sistem komutlarini (pre-built personality/mode) listeler.
GET /api/system-prompts{"prompts": [{"id": 1, "name": "Genel Asistan", "description": "Genel amacli AI asistani", "content": "Sen yardimci bir AI asistanisin..."}]}| Durum Kodu | Anlami | Aciklama |
|---|---|---|
| 200 | Basarili | Istek basariyla tamamlandi. |
| 400 | Hatali Istek | Eksik veya gecersiz parametreler. |
| 401 | Yetkisiz | Oturum acilmamis veya suresi dolmus. |
| 403 | Yasakli | Mesaj/token limiti asildi veya model erisim yetkisi yok. |
| 429 | Cok Fazla Istek | Rate limit asildi. Biraz bekleyin. |
| 404 | Bulunamadi | Belirtilen kaynak bulunamadi. |
| 500 | Sunucu Hatasi | API veya AI servisi hatasi. |
{
"error": "Hata aciklamasi",
"type": "limit_exceeded",
"upgrade_url": "/paketler"
}