v1API-Referenz
Ergo API Dokumentation
Alles, was du brauchst, um ergo-1.0 über eine OpenAI-kompatible API aufzurufen: Base-URL, Authentifizierung, Anfrageparameter, Streaming, Tool-Aufrufe, Fehler und Abrechnung.
- POST/v1/chat/completions
- GET/v1/models
Ergo API stellt Ergo 1.0 im OpenAI-Chat-Completions-Format bereit. Jeder Client, bei dem du die Base-URL ändern kannst, funktioniert ohne weitere Codeänderungen - abgesehen von URL, Modell-ID und Key.
- Base-URL
- https://ergollmapi.com/v1
- Modell-ID
- ergo-1.0
- Format
- OpenAI Chat Completions (JSON und server-sent events)
Sende deinen API-Key als Bearer-Token im Authorization-Header. Keys erstellst und widerrufst du nach dem Einloggen auf der API-Keys-Seite.
Authorization: Bearer $ERGO_API_KEYBewahre den Key auf deinem Server auf und lade ihn aus einer Umgebungsvariable wie ERGO_API_KEY. Gib ihn niemals in Browser-Code aus.
POSThttps://ergollmapi.com/v1/chat/completions
POST https://ergollmapi.com/v1/chat/completions erzeugt eine Modellantwort für eine Unterhaltung. Streaming ist standardmäßig aus: Lässt du stream weg, erhältst du eine einzelne JSON-Antwort. Das Beispiel unten setzt stream auf true.
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."}
]
}'Anfrageparameter
modelMust be "ergo-1.0". Any other value returns 400.
messagesNon-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.
streamDefault false. When omitted or false the response is a single JSON object; set true to receive server-sent events.
stream_optionsPassed through to the model, as in the OpenAI API.
max_tokensPositive integer upper bound on generated tokens. Values above 131072 are clamped to 131072 rather than rejected.
temperatureSampling temperature. Recommended: 1.0.
top_pNucleus sampling. Recommended: 0.99 (1.0 also works).
toolsFunction tool definitions in OpenAI format.
tool_choiceForwarded in OpenAI format: "auto", "none", "required", or {"type": "function", "function": {"name": "..."}} to force one function.
parallel_tool_callsAllow the model to return several tool calls in one turn.
response_formatStructured output request, for example {"type": "json_object"}.
reasoning_effortAccepted for compatibility. Ergo reasoning effort is fixed, so this value may be ignored.
Amazon empfiehlt für Ergo 1.0 temperature 1.0 und top_p 0.99. Ergo denkt vor jeder Antwort nach und der Reasoning-Aufwand ist fest, daher kann reasoning_effort ignoriert werden. max_tokens über 131072 wird auf 131072 begrenzt. Felder, die nicht in der Tabelle stehen, werden mit einem 400-Fehler abgelehnt.
Setze stream auf true, um server-sent events zu empfangen; ohne stream oder mit false liefert die API ein einzelnes JSON-Objekt. Reasoning kommt als reasoning_content-Deltas, die Antwort als content-Deltas. Der letzte Chunk vor data: [DONE] enthält usage und credits_consumed.
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]Übergib Funktionsdefinitionen in tools und lies die Aufrufe aus message.tool_calls. tool_choice akzeptiert "auto", "none", "required" oder einen Funktionsnamen, um einen Aufruf zu erzwingen; parallel_tool_calls erlaubt mehrere Aufrufe in einem Zug. Ergebnisse sendest du als Nachrichten mit der Rolle tool zurück.
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 listet die für deinen Key verfügbaren Modelle. Die Liste enthält ergo-1.0.
curl https://ergollmapi.com/v1/models \
-H "Authorization: Bearer $ERGO_API_KEY"Fehler
Fehler liefern einen HTTP-Status und einen JSON-Body mit einem error-Objekt, das message, type und code enthält.
{
"error": {
"message": "Insufficient credits.",
"type": "insufficient_quota",
"code": "insufficient_credits"
}
}- 400invalid_request_errorinvalid_request
Bedeutung: 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
Bedeutung: The API key is missing or invalid.
- 402insufficient_quotainsufficient_credits
Bedeutung: Your credit balance is too low for this request. Top up on the pricing page.
- 429rate_limit_errorrate_limit_exceeded
Bedeutung: Too many requests. Retry with exponential backoff.
- 502upstream_errorupstream_error
Bedeutung: The upstream provider returned an error.
- 503service_unavailableservice_unavailable
Bedeutung: The upstream provider is busy or timed out. Retry shortly.
Wiederhole Antworten 429, 502 und 503 mit exponentiellem Backoff. Wiederhole 400, 401 oder 402 erst, wenn du die Anfrage, den Key oder das Guthaben korrigiert hast.
Limits
- Nur Texteingabe. Bilder und Dateien werden nicht unterstützt.
- Kontextfenster: 1,048,576 Tokens.
- Maximale Ausgabe: 131,072 Tokens pro Anfrage (max_tokens bis 131072).
- Anfragen können rate-limitiert werden; eine 429-Antwort bedeutet: mit Backoff wiederholen.
Preise
Die Nutzung wird in Credits pro Token abgerechnet. Credit-Pakete und Abos findest du auf der Preisseite.
Jede Anfrage kostet mindestens 0.05 Credits.
Preise ansehen