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 페이지에서 키를 생성하고 폐기할 수 있습니다.
Authorization: Bearer $ERGO_API_KEY키는 서버에 보관하고 ERGO_API_KEY 같은 환경 변수에서 불러오세요. 브라우저 코드에 포함해서는 안 됩니다.
POSThttps://ergollmapi.com/v1/chat/completions
POST https://ergollmapi.com/v1/chat/completions은 대화에 대한 모델 응답을 생성합니다. 스트리밍은 기본적으로 꺼져 있습니다. stream을 생략하면 하나의 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."}
]
}'요청 파라미터
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은 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가 포함됩니다.
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는 한 턴에 여러 호출을 허용합니다. 결과는 tool 역할 메시지로 다시 보내세요.
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 https://ergollmapi.com/v1/models \
-H "Authorization: Bearer $ERGO_API_KEY"오류
오류는 HTTP 상태와 message, type, code를 포함하는 error 객체가 있는 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 응답은 백오프와 함께 재시도하라는 의미입니다.
요금
사용량은 토큰당 크레딧으로 과금됩니다. 크레딧 팩과 구독은 요금 페이지에서 확인하세요.
요청당 최소 0.05크레딧이 청구됩니다.
요금 보기