v1API başvurusu

Ergo API Belgeleri

ergo-1.0’ı OpenAI uyumlu bir API üzerinden çağırmak için gereken her şey: base URL, kimlik doğrulama, istek parametreleri, akış, araç çağrıları, hatalar ve faturalandırma.

  • POST/v1/chat/completions
  • GET/v1/models

Ergo API, Ergo 1.0’ı OpenAI Chat Completions formatında sunar. Base URL’yi değiştirmenize izin veren her istemci, URL, model id’si ve anahtar dışında kod değişikliği gerektirmeden çalışır.

Base URL
https://ergollmapi.com/v1
Model id
ergo-1.0
Format
OpenAI Chat Completions (JSON ve server-sent events)

API anahtarınızı Authorization başlığında Bearer token olarak gönderin. Anahtarları giriş yaptıktan sonra API Keys sayfasında oluşturup iptal edebilirsiniz.

HTTP başlığı
Authorization: Bearer $ERGO_API_KEY

Anahtarı sunucunuzda tutun ve ERGO_API_KEY gibi bir ortam değişkeninden yükleyin. Asla tarayıcı koduna eklemeyin.

API Keys’i aç

POSThttps://ergollmapi.com/v1/chat/completions

POST https://ergollmapi.com/v1/chat/completions, bir konuşma için model yanıtı oluşturur. Akış varsayılan olarak kapalıdır: stream’i eklemezseniz tek bir JSON yanıtı alırsınız. Aşağıdaki örnek stream’i true yapar.

curl https://ergollmapi.com/v1/chat/completions \
  -H "Authorization: Bearer $ERGO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ergo-1.0",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a Python function that merges two sorted lists."}
    ]
  }'

İstek parametreleri

  • modelstringZorunlu

    Must be "ergo-1.0". Any other value returns 400.

  • messagesarrayZorunlu

    Non-empty array of messages with role system, developer, user, assistant or tool. content is a string or an array of text parts. Images and files are not supported.

  • streambooleanİsteğe bağlı

    Default false. When omitted or false the response is a single JSON object; set true to receive server-sent events.

  • stream_optionsobjectİsteğe bağlı

    Passed through to the model, as in the OpenAI API.

  • max_tokensintegerİsteğe bağlı

    Positive integer upper bound on generated tokens. Values above 131072 are clamped to 131072 rather than rejected.

  • temperaturenumberİsteğe bağlı

    Sampling temperature. Recommended: 1.0.

  • top_pnumberİsteğe bağlı

    Nucleus sampling. Recommended: 0.99 (1.0 also works).

  • toolsarrayİsteğe bağlı

    Function tool definitions in OpenAI format.

  • tool_choicestring | objectİsteğe bağlı

    Forwarded in OpenAI format: "auto", "none", "required", or {"type": "function", "function": {"name": "..."}} to force one function.

  • parallel_tool_callsbooleanİsteğe bağlı

    Allow the model to return several tool calls in one turn.

  • response_formatobjectİsteğe bağlı

    Structured output request, for example {"type": "json_object"}.

  • reasoning_effortstringİsteğe bağlı

    Accepted for compatibility. Ergo reasoning effort is fixed, so this value may be ignored.

Amazon, Ergo 1.0 için temperature 1.0 ve top_p 0.99 önerir. Ergo yanıt vermeden önce her zaman akıl yürütür ve akıl yürütme düzeyi sabit olduğundan reasoning_effort yok sayılabilir. 131072 üzerindeki max_tokens 131072’ye kırpılır. Tabloda listelenmeyen alanlar 400 hatasıyla reddedilir.

server-sent events almak için stream’i true yapın; stream yoksa veya false ise API tek bir JSON nesnesi döndürür. Akıl yürütme reasoning_content deltaları, yanıt content deltaları olarak gelir. data: [DONE] öncesindeki son parça usage ve credits_consumed taşır.

SSE
data: {"choices":[{"delta":{"reasoning_content":"The user wants a merge function..."}}]}

data: {"choices":[{"delta":{"content":"def merge(a, b):"}}]}

data: {"choices":[],"usage":{"prompt_tokens":24,"completion_tokens":212,"total_tokens":236},"credits_consumed":0.2}

data: [DONE]

Fonksiyon tanımlarını tools içinde geçin ve çağrıları message.tool_calls üzerinden okuyun. tool_choice "auto", "none", "required" veya bir çağrıyı zorlamak için fonksiyon adı kabul eder; parallel_tool_calls tek turda birden çok çağrıya izin verir. Sonuçları tool rolü mesajları olarak geri gönderin.

Python
import json, os
from openai import OpenAI

client = OpenAI(base_url="https://ergollmapi.com/v1", api_key=os.environ["ERGO_API_KEY"])

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        },
    },
}]

response = client.chat.completions.create(
    model="ergo-1.0",
    messages=[{"role": "user", "content": "What is the weather in Oslo?"}],
    tools=tools,
)

call = response.choices[0].message.tool_calls[0]
print(call.function.name, json.loads(call.function.arguments))

GEThttps://ergollmapi.com/v1/models

GET https://ergollmapi.com/v1/models, anahtarınızın erişebildiği modelleri döndürür. Liste ergo-1.0 içerir.

curl
curl https://ergollmapi.com/v1/models \
  -H "Authorization: Bearer $ERGO_API_KEY"

Hatalar bir HTTP durumu ve message, type, code içeren bir error nesnesi taşıyan JSON gövdesi döndürür.

JSON
{
  "error": {
    "message": "Insufficient credits.",
    "type": "insufficient_quota",
    "code": "insufficient_credits"
  }
}
  • 400invalid_request_errorinvalid_request

    Anlam: The request is invalid: a missing or wrong-typed field, an unsupported field, a model other than ergo-1.0, or non-text content.

  • 401authentication_errorinvalid_api_key

    Anlam: The API key is missing or invalid.

  • 402insufficient_quotainsufficient_credits

    Anlam: Your credit balance is too low for this request. Top up on the pricing page.

  • 429rate_limit_errorrate_limit_exceeded

    Anlam: Too many requests. Retry with exponential backoff.

  • 502upstream_errorupstream_error

    Anlam: The upstream provider returned an error.

  • 503service_unavailableservice_unavailable

    Anlam: The upstream provider is busy or timed out. Retry shortly.

429, 502 ve 503 yanıtlarını üstel geri çekilmeyle yeniden deneyin. İsteği, anahtarı veya bakiyeyi düzeltmeden 400, 401 veya 402’yi yeniden denemeyin.

  • Yalnızca metin girdisi. Görüntüler ve dosyalar desteklenmez.
  • Bağlam penceresi: 1,048,576 token.
  • Maksimum çıktı: istek başına 131,072 token (max_tokens 131072’ye kadar).
  • İstekler hız sınırına takılabilir; 429 yanıtı geri çekilmeyle yeniden deneme anlamına gelir.

Kullanım token başına krediyle faturalandırılır. Kredi paketleri ve abonelikler fiyatlandırma sayfasındadır.

Model1M token başına girdi1M token başına çıktı
ergo-1.01M token başına girdi300 kredi1M token başına çıktı900 kredi

Her istek en az 0.05 kredi tutar.

Fiyatları gör