api referansı
LyDian enterprise ai platformu için kapsamlı api dokümantasyonu. tüm endpoint'ler, parametreler ve örnek kullanımlar.
kimlik doğrulama
tüm api istekleri bearer token ile kimlik doğrulaması gerektirir. token'ı authorization header'ında göndermeniz gerekir.
curl -X GET http://localhost:3100/api/models \ -H "Authorization: Bearer sk-lydian-xxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json"
- api anahtarınızı asla public repository'lerde paylaşmayın
- environment değişkenlerinde saklayın
- client-side kodda kullanmayın
- periyodik olarak anahtarlarınızı yenileyin
ai modelleri ile sohbet oluşturur. 23 farklı modelden seçim yapabilirsiniz.
| parametre | tip | zorunlu | açıklama |
|---|---|---|---|
| message | string | evet | kullanıcı mesajı |
| model | string | hayır | kullanılacak model (varsayılan: gpt-4) |
| stream | boolean | hayır | streaming modu (varsayılan: false) |
| temperature | number | hayır | 0-1 arası, yaratıcılık seviyesi |
const response = await fetch('http://localhost:3100/api/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'yapay zeka nedir?',
model: 'gpt-4',
temperature: 0.7
})
});
const data = await response.json();
console.log(data.response);
{
"success": true,
"response": "yapay zeka, makinelerin insan benzeri...",
"model": "gpt-4",
"tokens": 156,
"timestamp": "2024-01-15T10:30:00Z"
}
gerçek zamanlı streaming ile yanıt alın. her token geldiğinde anında gösterilir.
const response = await fetch('http://localhost:3100/api/chat', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'uzun bir makale yaz',
stream: true
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
process.stdout.write(chunk); // her kelime geldiğinde yazdır
}
tüm kullanılabilir ai modellerini listeler. her modelin özellikleri ve limitleri dahil.
curl -X GET http://localhost:3100/api/models \ -H "Authorization: Bearer YOUR_API_KEY"
{
"models": [
{
"id": "gpt-4",
"name": "GPT-4 Omni",
"provider": "openai",
"capabilities": ["chat", "vision", "code"],
"max_tokens": 128000
},
{
"id": "enterprise-ai-3.5-sonnet",
"name": "Ultra Intelligence Model",
"provider": "advanced-ai-platform",
"capabilities": ["chat", "code", "analysis"],
"max_tokens": 200000
}
]
}
görsel analizi yapar. nesne tespiti, yüz tanıma, ocr ve içerik moderasyonu.
| parametre | tip | zorunlu | açıklama |
|---|---|---|---|
| image | string | evet | base64 encoded görsel veya url |
| task | string | evet | detect, ocr, moderate, describe |
const response = await fetch('http://localhost:3100/api/vision', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
image: 'https://example.com/image.jpg',
task: 'describe'
})
});
const data = await response.json();
metin açıklamasından yüksek kaliteli görseller oluşturur. dall-e 3 modeli ile.
| parametre | tip | zorunlu | açıklama |
|---|---|---|---|
| prompt | string | evet | görsel açıklaması |
| size | string | hayır | 1024x1024, 1792x1024, 1024x1792 |
| quality | string | hayır | standard, hd |
const response = await fetch('http://localhost:3100/api/generate-image', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'güneş batımında minimalist bir dağ manzarası',
size: '1024x1024',
quality: 'hd'
})
});
84 dil desteği ile metin çevirisi. z.ai dil paketi kullanır.
| parametre | tip | zorunlu | açıklama |
|---|---|---|---|
| text | string | evet | çevrilecek metin |
| from | string | hayır | kaynak dil (auto detect) |
| to | string | evet | hedef dil kodu |
const response = await fetch('http://localhost:3100/api/translate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'hello world',
to: 'tr'
})
});
hata kodları
| kod | durum | açıklama |
|---|---|---|
| 400 | bad request | geçersiz istek formatı veya parametreler |
| 401 | unauthorized | geçersiz veya eksik api anahtarı |
| 403 | forbidden | bu kaynağa erişim izniniz yok |
| 429 | rate limit | çok fazla istek, daha sonra tekrar deneyin |
| 500 | server error | sunucu hatası, destek ekibiyle iletişime geçin |
rate limiting
api istekleriniz plan tipinize göre sınırlandırılmıştır.
| plan | istek/dakika | istek/gün | token limiti |
|---|---|---|---|
| free | 10 | 100 | 10k tokens |
| starter | 60 | 10,000 | 100k tokens |
| pro | 300 | 100,000 | 1M tokens |
| enterprise | unlimited | unlimited | unlimited |