Uç noktalar
Kararlar
api14 üzerinde POST /decisions ile karar modellerini kullanarak içeriği sınıflandırın, yönlendirin ve puanlayın. Tipli sorular gider, kalibre olasılıklar döner.
Playground’da deneKarar modelleri bir içeriği (state) okur ve onunla ilgili tipli sorulara serbest metin yerine olasılıklarla cevap verir. Yönlendirme, moderasyon, önceliklendirme ve ölçüte göre puanlama gibi öngörülebilir, makinenin okuyabileceği bir cevap gereken işler için kullanın.
POST https://api14.com/api/v1/decisions
Karar modelleri /chat/completions ucunu kabul etmez. Resmi OpenAI SDK'larında decisions metodu yoktur; düz HTTP ya da SDK'nın genel post metoduyla çağırın (aşağıdaki her örnek böyle yapar).
İstek
| Parametre | Tür | Zorunlu | Açıklama |
|---|---|---|---|
model | string | evet | Bir karar modeli kimliği, örn. liquid/d1. |
state | string, nesne ya da dizi | evet | Değerlendirilecek içerik: bir mesaj, bir konuşma, bir belge. |
questions | nesne | evet | Adlandırılmış sorular. Her anahtar sizindir ve answers içinde aynı adla döner. |
provider | nesne | hayır | Sağlayıcı yönlendirme tercihleri. |
session_id | string | hayır | İlgili istekleri gruplar. |
user | string | hayır | Son kullanıcınızın kimliği. |
Soru tipleri
Her sorunun type, instructions ve criteria alanı vardır.
type | criteria | Cevap |
|---|---|---|
choice | Seçenek adından açıklamaya nesne. | choice (en olası seçenek), confidence, seçenek başına probabilities. |
noul | true ve false anahtarlı nesne. | noul: true olma olasılığı. |
score | Sıralı seviyeler dizisi (en az bir). | score (olasılık ağırlıklı konum), confidence, seviye başına probabilities. |
Örnek
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api14.com/api/v1",
apiKey: process.env.API14_API_KEY,
});
const result = await client.post("/decisions", { body: {
"model": "liquid/d1",
"state": "Customer: I was charged twice for my order and want my money back.",
"questions": {
"team": {
"type": "choice",
"instructions": "Which team should handle this message?",
"criteria": {
"billing": "Payments, refunds, invoices",
"support": "Product questions and bugs",
"sales": "Pricing and new purchases"
}
},
"urgent": {
"type": "noul",
"instructions": "Does this need a reply today?",
"criteria": {
"true": "Money, outage or legal risk",
"false": "Can wait"
}
}
}
} });
console.log(result.answers);
curl https://api14.com/api/v1/decisions \
-H "Authorization: Bearer sk-api14-..." \
-H "Content-Type: application/json" \
-d '{
"model": "liquid/d1",
"state": "Customer: I was charged twice for my order and want my money back.",
"questions": {
"team": {
"type": "choice",
"instructions": "Which team should handle this message?",
"criteria": { "billing": "Payments, refunds, invoices", "support": "Product questions and bugs", "sales": "Pricing and new purchases" }
},
"urgent": {
"type": "noul",
"instructions": "Does this need a reply today?",
"criteria": { "true": "Money, outage or legal risk", "false": "Can wait" }
}
}
}'
Yanıt
{
"id": "gen-dec-1791900000-a1",
"model": "liquid/d1",
"answers": {
"team": { "type": "choice", "choice": "billing", "confidence": 0.93, "probabilities": { "billing": 0.93, "support": 0.05, "sales": 0.02 } },
"urgent": { "type": "noul", "noul": 0.81 }
},
"usage": { "input_tokens": 142, "output_tokens": 0, "cost": 0.0000071 }
}
Her cevabın yanına yanıttaki model değerini kaydedin: ~typesafe/jev-latest gibi bir takma ad ileride daha yeni bir sürümü gösterebilir.
Fiyatlandırma
Karar modelleri, modelin listelenen fiyatıyla giriş jetonu başına ücretlendirilir. Çıkış jetonları ücretsizdir. Bedel usage.cost alanındadır ve USD bakiyenizden düşülür.
Karar modellerini listeleme
curl "https://api14.com/api/v1/models?category=decisions"
Hatalar
| Durum | Kod | Ne zaman |
|---|---|---|
| 400 | model_required / invalid_json | model eksik ya da gövde bozuk. |
| 402 | insufficient_balance | USD bakiyeniz $0. |
| 403 | model_not_allowed | Anahtarın izin listesi modeli dışarıda bırakıyor. |
| 404 | model_not_found | Bilinmeyen ya da kapalı model kimliği. |
| 429 | rate_limited | Dakikalık istek sınırı aşıldı. |
Bkz. Hatalar.