Ferman AI API Dokümantasyonu
REST API — OpenAI istemcileriyle uyumlu format, herhangi bir HTTP istemcisiyle kullanabilirsiniz.
Kimlik Doğrulama
Tüm API isteklerinde Authorization header'ına API anahtarınızı ekleyin:
Authorization: Bearer fai_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
API anahtarı oluşturmak için Dashboard → API sayfasını ziyaret edin.
Rate Limits
Her API isteği aylık API çağrı kotanıza sayılır. Kota aşıldığında 429 Too Many Requests döner.
Her mesajdaki token tüketimi de toplam token kullanımınıza işlenir ve dashboard'da görüntülenebilir.
Plan Limitleri
| Plan | Aylık API Çağrısı | Dosya Yükleme | Max Dosya |
|---|---|---|---|
| Free | 500 | ❌ | — |
| Basic | 2.000 | ✅ | 5 MB |
| Standard | 10.000 | ✅ | 5 MB |
| Pro | 50.000 | ✅ | 5 MB |
| Premium | 200.000 | ✅ | 10 MB |
| Elite | Sınırsız | ✅ | 10 MB |
Endpoint: Modeller
GET
/api/v1/models
Kullanılabilir modelleri listeler
Yanıt Örneği
{
"object": "list",
"data": [
{
"id": "ferman3.5",
"object": "model",
"owned_by": "ollama"
}
]
}
Endpoint: Chat Completions
POST
/api/v1/chat/completions
Mesaj gönder ve yanıt al
İstek Parametreleri
| Parametre | Tip | Açıklama |
|---|---|---|
| modelzorunlu | string | Kullanılacak model ID (örn: ferman3.5) |
| messageszorunlu | array | Sohbet geçmişi — [{role, content}] formatında |
| streamisteğe bağlı | boolean | SSE stream ile yanıt al (varsayılan: false) |
| temperatureisteğe bağlı | number | Yanıt yaratıcılığı 0–2 arası (varsayılan: 0.7) |
| max_tokensisteğe bağlı | integer | Maksimum çıktı token sayısı |
İstek Örneği
{
"model": "ferman3.5",
"messages": [
{ "role": "system", "content": "Sen yardımcı bir asistansın." },
{ "role": "user", "content": "Merhaba, nasıl çalışıyorsun?" }
],
"stream": false
}
Başarılı Yanıt
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1741000000,
"model": "ferman3.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Merhaba! Ben Ferman AI, size nasıl yardımcı olabilirim?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 18,
"total_tokens": 42
}
}
Hata Yanıtları
| HTTP Kodu | Açıklama |
|---|---|
| 401 | Geçersiz veya eksik API anahtarı |
| 403 | Hesap askıya alınmış |
| 429 | Aylık API kota aşıldı |
| 500 | Sunucu / model hatası |
Chat API: Sohbet Listesi
GET
/api/chat/list
Sohbetleri listeler
Query: ?q=arama (isteğe bağlı)
{ "success": true, "chats": [{ "id": 42, "title": "Merhaba", "slug": "merhaba-a1b2", "model": "ferman3.5", "message_count": 5 }] }
Chat API: Sohbet Oluştur
POST
/api/chat/create
Yeni sohbet oluşturur
| Parametre | Tip | Açıklama |
|---|---|---|
| titleisteğe bağlı | string | Başlık (varsayılan: "Yeni Sohbet") |
| modelisteğe bağlı | string | Model |
{ "success": true, "chat_id": 43, "slug": "python-x9k2", "title": "Python" }
Chat API: Sohbet Geçmişi
GET
/api/chat/{id}/history
Mesaj geçmişini getirir
{ "success": true, "chat": { "id": 42, "title": "Merhaba" }, "messages": [{ "id": 101, "role": "user", "content": "Merhaba!", "token_count": 12 }, { "id": 102, "role": "assistant", "content": "Yardımcı olabilirim?", "token_count": 18 }] }
Chat API: Mesaj Gönder (SSE)
POST
/api/chat/{id}/send
Mesaj gönderir — yanıt SSE stream
| Parametre | Tip | Açıklama |
|---|---|---|
| messagezorunlu | string | Mesaj metni |
SSE Yanıt Formatı
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Merhaba"},"finish_reason":null}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}],"done":true}
data: [DONE]
| HTTP Kodu | Açıklama |
|---|---|
| 401 | Kimlik doğrulama başarısız |
| 429 | Günlük limit / rate limit aşıldı |
Chat API: Sohbet Güncelle
PUT
/api/chat/{id}
Başlık veya arşiv durumunu günceller
| Parametre | Tip | Açıklama |
|---|---|---|
| titleisteğe bağlı | string | Yeni başlık (max 200) |
| archivedisteğe bağlı | boolean | Arşivle/çıkar |
{ "success": true, "message": "Güncellendi" }
Chat API: Sohbet Sil
DELETE
/api/chat/{id}
Sohbeti kalıcı olarak siler
Sohbet ve tüm mesajları kalıcı silinir. Geri alınamaz.
{ "success": true, "message": "Sohbet silindi" }
Chat API: Mesaj Tepkisi
POST
/api/chat/{chatId}/message/{msgId}/react
Mesaja tepki verir
| Parametre | Tip | Açıklama |
|---|---|---|
| reactionzorunlu | integer | 1 = beğen, -1 = beğenme, 0 = kaldır |
{ "success": true, "message": "Kaydedildi" }
Örnek: cURL
curl -X POST https://ferman.net.tr/api/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer fai_ANAHTARINIZ" \
-d '{
"model": "ferman3.5",
"messages": [
{"role": "user", "content": "Merhaba!"}
]
}'
Örnek: PHP
<?php
$ch = curl_init('https://ferman.net.tr/api/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer fai_ANAHTARINIZ',
],
CURLOPT_POSTFIELDS => json_encode([
'model' => 'ferman3.5',
'messages' => [
['role' => 'user', 'content' => 'Merhaba!'],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
echo $response['choices'][0]['message']['content'];
Örnek: Python (requests)
import requests
response = requests.post(
'https://ferman.net.tr/api/v1/chat/completions',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer fai_ANAHTARINIZ',
},
json={
'model': 'ferman3.5',
'messages': [
{'role': 'user', 'content': 'Merhaba!'}
]
}
)
print(response.json()['choices'][0]['message']['content'])
Örnek: JavaScript (fetch)
const response = await fetch('https://ferman.net.tr/api/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer fai_ANAHTARINIZ',
},
body: JSON.stringify({
model: 'ferman3.5',
messages: [
{ role: 'user', content: 'Merhaba!' }
]
})
});
const data = await response.json();
// data.choices[0].message.content