v1Referencia de la API

Documentación de Ergo API

Todo lo necesario para llamar a ergo-1.0 a través de una API compatible con OpenAI: URL base, autenticación, parámetros de solicitud, streaming, llamadas a herramientas, errores y facturación.

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

Ergo API expone Ergo 1.0 en el formato OpenAI Chat Completions. Cualquier cliente que permita cambiar la URL base funciona sin más cambios de código que la URL, el id del modelo y la clave.

URL base
https://ergollmapi.com/v1
Id del modelo
ergo-1.0
Formato
OpenAI Chat Completions (JSON y server-sent events)

Envía tu clave de API como token Bearer en la cabecera Authorization. Crea y revoca claves en la página API Keys después de iniciar sesión.

Cabecera HTTP
Authorization: Bearer $ERGO_API_KEY

Guarda la clave en tu servidor y cárgala desde una variable de entorno como ERGO_API_KEY. Nunca la incluyas en código del navegador.

Abrir API Keys

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

POST https://ergollmapi.com/v1/chat/completions crea una respuesta del modelo para una conversación. El streaming está desactivado por defecto: si omites stream obtienes una única respuesta JSON. El ejemplo siguiente establece stream en 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."}
    ]
  }'

Parámetros de la solicitud

  • modelstringObligatorio

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

  • messagesarrayObligatorio

    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.

  • streambooleanOpcional

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

  • stream_optionsobjectOpcional

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

  • max_tokensintegerOpcional

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

  • temperaturenumberOpcional

    Sampling temperature. Recommended: 1.0.

  • top_pnumberOpcional

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

  • toolsarrayOpcional

    Function tool definitions in OpenAI format.

  • tool_choicestring | objectOpcional

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

  • parallel_tool_callsbooleanOpcional

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

  • response_formatobjectOpcional

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

  • reasoning_effortstringOpcional

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

Amazon recomienda temperature 1.0 y top_p 0.99 para Ergo 1.0. Ergo siempre razona antes de responder y su esfuerzo de razonamiento es fijo, por lo que reasoning_effort puede ignorarse. max_tokens por encima de 131072 se limita a 131072. Los campos no incluidos en la tabla se rechazan con un error 400.

Establece stream en true para recibir server-sent events; si stream se omite o es false, la API devuelve un único objeto JSON. El razonamiento llega como deltas de reasoning_content y la respuesta como deltas de content. El último chunk antes de data: [DONE] incluye usage y 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]

Pasa las definiciones de funciones en tools y lee las llamadas desde message.tool_calls. tool_choice acepta "auto", "none", "required" o el nombre de una función para forzar una llamada; parallel_tool_calls permite varias llamadas en un turno. Devuelve los resultados como mensajes con rol 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 devuelve los modelos disponibles para tu clave. La lista contiene ergo-1.0.

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

Los errores devuelven un estado HTTP y un cuerpo JSON con un objeto error que contiene message, type y code.

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

    Significado: 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

    Significado: The API key is missing or invalid.

  • 402insufficient_quotainsufficient_credits

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

  • 429rate_limit_errorrate_limit_exceeded

    Significado: Too many requests. Retry with exponential backoff.

  • 502upstream_errorupstream_error

    Significado: The upstream provider returned an error.

  • 503service_unavailableservice_unavailable

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

Reintenta las respuestas 429, 502 y 503 con backoff exponencial. No reintentes 400, 401 o 402 hasta haber corregido la solicitud, la clave o el saldo.

  • Solo entrada de texto. No se admiten imágenes ni archivos.
  • Ventana de contexto: 1,048,576 tokens.
  • Salida máxima: 131,072 tokens por solicitud (max_tokens hasta 131072).
  • Las solicitudes pueden estar limitadas en frecuencia; una respuesta 429 significa reintentar con backoff.

El uso se factura en créditos por token. Los paquetes de créditos y las suscripciones están en la página de precios.

ModeloEntrada por 1M tokensSalida por 1M tokens
ergo-1.0Entrada por 1M tokens300 créditosSalida por 1M tokens900 créditos

Cada solicitud cuesta al menos 0.05 créditos.

Ver precios