v1API リファレンス

Ergo API ドキュメント

OpenAI 互換 API で ergo-1.0 を呼び出すために必要なすべて:base URL、認証、リクエストパラメータ、ストリーミング、ツール呼び出し、エラー、課金。

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

Ergo API は Ergo 1.0 を OpenAI Chat Completions 形式で提供します。base URL を変更できるクライアントなら、URL・モデル id・キー以外のコード変更なしに利用できます。

Base URL
https://ergollmapi.com/v1
モデル id
ergo-1.0
形式
OpenAI Chat Completions(JSON および server-sent events)

APIキーは Authorization ヘッダーで Bearer トークンとして送信します。キーの作成と失効は、ログイン後の API Keys ページで行えます。

HTTP ヘッダー
Authorization: Bearer $ERGO_API_KEY

キーはサーバーに置き、ERGO_API_KEY などの環境変数から読み込んでください。ブラウザのコードに含めてはいけません。

API Keys を開く

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

POST https://ergollmapi.com/v1/chat/completions は会話に対するモデル応答を作成します。ストリーミングはデフォルトでオフです:stream を省略すると 1 つの JSON 応答が返ります。以下の例では stream を 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."}
    ]
  }'

リクエストパラメータ

  • modelstring必須

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

  • messagesarray必須

    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任意

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

  • stream_optionsobject任意

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

  • max_tokensinteger任意

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

  • temperaturenumber任意

    Sampling temperature. Recommended: 1.0.

  • top_pnumber任意

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

  • toolsarray任意

    Function tool definitions in OpenAI format.

  • tool_choicestring | object任意

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

  • parallel_tool_callsboolean任意

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

  • response_formatobject任意

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

  • reasoning_effortstring任意

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

Amazon は Ergo 1.0 に temperature 1.0 と top_p 0.99 を推奨しています。Ergo は回答前に必ず推論を行い、その推論の強度は固定のため、reasoning_effort は無視されることがあります。131072 を超える max_tokens は 131072 に切り詰められます。表にないフィールドは 400 エラーで拒否されます。

stream を true にすると server-sent events を受信できます。stream が省略または false の場合、API は単一の JSON オブジェクトを返します。推論は reasoning_content の差分として、回答は content の差分として届きます。data: [DONE] の直前の最後のチャンクには usage と credits_consumed が含まれます。

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]

tools に関数定義を渡し、呼び出しは message.tool_calls から読み取ります。tool_choice は "auto"、"none"、"required" のほか、呼び出しを強制する関数名を指定できます。parallel_tool_calls で 1 ターンに複数の呼び出しを許可できます。結果は tool ロールのメッセージとして返送します。

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 はキーで利用可能なモデルを返します。リストには ergo-1.0 が含まれます。

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

エラーは HTTP ステータスと、message・type・code を含む error オブジェクトを持つ JSON ボディを返します。

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

    意味: 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

    意味: The API key is missing or invalid.

  • 402insufficient_quotainsufficient_credits

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

  • 429rate_limit_errorrate_limit_exceeded

    意味: Too many requests. Retry with exponential backoff.

  • 502upstream_errorupstream_error

    意味: The upstream provider returned an error.

  • 503service_unavailableservice_unavailable

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

429、502、503 の応答は指数バックオフでリトライしてください。400、401、402 はリクエスト・キー・残高を修正するまでリトライしないでください。

  • テキスト入力のみ。画像やファイルはサポートされません。
  • コンテキストウィンドウ:1,048,576 トークン。
  • 最大出力:リクエストあたり 131,072 トークン(max_tokens は 131072 まで)。
  • リクエストはレート制限される場合があります。429 応答はバックオフ付きでリトライしてください。

使用量はトークン単位でクレジット課金されます。クレジットパックとサブスクリプションは料金ページにあります。

モデル入力 1M トークンあたり出力 1M トークンあたり
ergo-1.0入力 1M トークンあたり300 クレジット出力 1M トークンあたり900 クレジット

各リクエストは最低 0.05 クレジットかかります。

料金を見る