Browse documentation

Reference · Launch preview. EvaEsi has not launched.

Responses API

Use the canonical public inference route for single-shot generation, usage accounting, and optional SSE streaming.

On this page

Endpoint#

HTTPEndpoint
POST https://evaesi.dev/api/v1/responses

The older POST /api/v1/chat route remains mounted as a compatibility alias, but /api/v1/responses is the forward contract.

Request body#

FieldTypeRequiredDescription
promptstringYesPrompt text to dispatch through the inference gateway.
levelstring?NoThe effort level: "look", "focus", "duet", "high" or "hyper". If omitted, the server uses focus.
max_output_rungsu64?NoOptional hard output cap. If omitted, budget reservation falls back to the level's output limit.
include_regionsbool?NoExpose region metadata in usage where available.
studio_idstring?NoOptional studio context.
custom_instructionsstring?NoOptional instruction override.
web_searchboolNoFavor fresh retrieval where supported.
code_modeboolNoCode and documentation mode.
image_modeboolNoImage or visual mode.
streambool?NoEnable SSE streaming on the same route.

Live validation rejects empty prompts and prompts over 100000 bytes. If include_regions is enabled today, the field is reserved in the response but currently reports 0 because the live gateway does not emit region activations yet.

Response#

JSONResponse
{
  "request_id": "uuid",
  "content": "Generated text...",
  "sources": [],
  "sources_url": "/api/v1/sources/uuid",
  "usage": {
    "input_rungs": 29,
    "output_rungs": 118,
    "total_rungs": 147,
    "regions_activated": null
  },
  "level": "focus"
}

The live response payload emits sources_url as /api/v1/sources/{request_id}. The nested /api/v1/responses/{request_id}/sources path remains mounted as a compatible alias.

Streaming#

When stream: true, the same endpoint returns server-sent events. Current live event names are:

EventMeaning
response.output_text.deltaPartial output chunk
response.completedFinal completion payload
response.errorStream-level error payload

At stream start, the response headers include input-rung and rate-limit metadata. Output and total rung counts are only known when generation completes and are delivered in the final completion payload. Each data: line is the JSON-serialized InferenceChunk, including index, content, done, request_id, and model.

Server-sent eventsStreaming
event: response.output_text.delta
data: {"index":0,"content":"The ","done":false,"request_id":"req_abc","model":"evaesi-1.0"}

event: response.output_text.delta
data: {"index":1,"content":"answer ","done":false,"request_id":"req_abc","model":"evaesi-1.0"}

event: response.completed
data: {"index":42,"content":"","done":true,"request_id":"req_abc","model":"evaesi-1.0","sources":[]}

Examples#

cURL

ShellcURL
curl -X POST https://evaesi.dev/api/v1/responses \
      -H "Authorization: Bearer esi_dev_YOUR_KEY" \
      -H "Content-Type: application/json" \
  -d '{
    "prompt": "What is the capital of France?",
    "level": "focus",
    "web_search": true
  }'

Python

PythonPython
import requests

response = requests.post(
    "https://evaesi.dev/api/v1/responses",
    headers={"Authorization": "Bearer esi_dev_YOUR_KEY"},
    json={
        "prompt": "What is the capital of France?",
        "level": "focus",
        "web_search": True,
    },
)

data = response.json()
print(data["content"])
print(f"Used {data['usage']['input_rungs']} input rungs")

JavaScript

JavaScriptJavaScript
const response = await fetch("https://evaesi.dev/api/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer esi_dev_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "What is the capital of France?",
    level: "focus",
    web_search: true,
  }),
});

const data = await response.json();
console.log(data.content);

Streaming example#

JavaScriptStreaming example
const response = await fetch("https://evaesi.dev/api/v1/responses", {
  method: "POST",
  headers: {
    "Authorization": "Bearer esi_dev_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "Explain gravity.",
    level: "focus",
    stream: true,
  }),
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  const text = decoder.decode(value, { stream: true });
  for (const line of text.split("\n")) {
    if (line.startsWith("data: ")) {
      const chunk = JSON.parse(line.slice(6));
      if (chunk.done) {
        console.log("\nrequest_id:", chunk.request_id);
        break;
      }
      process.stdout.write(chunk.content ?? "");
    }
  }
}