API reference

Base URL https://api.foglare.com. Free to use; inference requires a sk-fog- API key from the dashboard (or a signed-in browser session). Three inference endpoints in OpenAI and Anthropic wire formats, plus model discovery.

Endpoints

Method Path Auth Response
POST /v1/chat/completions key or session SSE, always
POST /v1/messages key or session SSE, always
POST /v1/responses key or session JSON, or SSE with stream:true
GET /v1/models none JSON list of model ids
GET /v1/models/:id none JSON model object, or 404
GET /api/models none JSON catalog with health

The gateway resolves the model field to live provider capacity on every request. You choose a size, a speed or a model id, never a vendor. No charge, no paid tier.

Authentication

Caller Credential Capacity
API key Authorization: Bearer sk-fog-…, created in the dashboard Your account: per-key usage stats, saved pins, linked Logfare capacity
Browser, signed in foglair_session cookie, set by GitHub sign-in Shared pool, plus your pinned or linked Logfare capacity
No credential Rejected with 401 on inference endpoints Model discovery only

Create an API key (sk-fog-…) from the dashboard and send it as a bearer token; keys are shown once at creation. A valid key identifies your account on every request and wins over the session cookie when both are present. Inference requires a key or a signed-in session — anonymous calls are rejected with 401. Sign-in sets one HttpOnly session cookie for browser requests. Linking your own Logfare account adds it as a provider you can pin per model; it does not go first automatically. Pinned requests respect your Logfare account limits.

Models and routing tiers

Send a routing tier or a direct model id in the model field. Direct ids carry no suffix. The full list with live status is on the models page, GET /v1/models and GET /api/models.

Model id Routes to
auto:fastLowest time to first token across all sizes. Default for chat.
auto:SSmall. Short completions, classification, extraction.
auto:MMedium. Everyday chat and summarization.
auto:LLarge. Multi-step reasoning and longer code.
auto:XLExtra large. The deepest reasoning tier.
qwen4-maxDirect id example. Any served model id works the same way.

Reasoning effort

Set reasoning_effort to a level the model accepts, for example low, high, xhigh or max. Levels differ per model; the exact set is in reasoning_levels on each model card and in GET /api/models. On /v1/responses the field is reasoning.effort.

Request body

{
  "model": "qwen4-max",
  "reasoning_effort": "high",
  "messages": [{ "role": "user", "content": "Prove there are infinitely many primes." }]
}

Chat completions

POST /v1/chat/completions, OpenAI chat format. The response is always an SSE stream of chat.completion.chunk objects, terminated by data: [DONE].

Field Type Default Notes
modelstringrequiredTier or direct id.
messagesarrayrequiredrole and string content per message.
streamboolfalseResponse is SSE either way.
temperaturenumberupstreamForwarded when set.
max_tokensintegerupstreamForwarded when set.
reasoning_effortstringnonePer-model levels, see above.
providerstringnoneOne-request pin by codename.
previous_response_idstringnoneAffinity echo, see pinning.

curl

curl -N https://api.foglare.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"auto:fast","stream":true,"messages":[{"role":"user","content":"Hello"}]}'

Python, openai SDK

from openai import OpenAI

# Use your sk-fog-... key from the dashboard. Inference requires a key.
client = OpenAI(base_url="https://api.foglare.com/v1", api_key="sk-fog-YOUR_KEY")

stream = client.chat.completions.create(
    model="auto:fast",
    messages=[{"role": "user", "content": "Hello"}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)

JavaScript, fetch

// In a browser your Foglare session cookie is sent automatically.
const response = await fetch("https://api.foglare.com/v1/chat/completions", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  credentials: "include",
  body: JSON.stringify({
    model: "auto:fast",
    stream: true,
    messages: [{ role: "user", content: "Hello" }]
  })
});

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

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  buffer += decoder.decode(value, { stream: true });
  const lines = buffer.split("\n");
  buffer = lines.pop();
  for (const line of lines) {
    if (!line.startsWith("data: ")) continue;
    const payload = line.slice(6).trim();
    if (payload === "[DONE]") continue;
    const chunk = JSON.parse(payload);
    const text = chunk.choices?.[0]?.delta?.content;
    if (text) document.getElementById("out").append(text);
  }
}

Messages

POST /v1/messages, Anthropic messages format. Same tiers and model ids. The response is always SSE: message_start, then content_block_delta events carrying text_delta, ending with message_stop.

Field Type Default Notes
modelstringrequiredTier or direct id.
messagesarrayrequiredrole and string content.
max_tokensintegerrequiredAnthropic requires it; send a generous cap.
systemstringnonePrepended as a system message.
streamboolfalseResponse is SSE either way.
temperaturenumberupstreamForwarded when set.
reasoning_effortstringnonePer-model levels.
providerstringnoneOne-request pin by codename.
previous_response_idstringnoneAffinity echo.

curl

curl -N https://api.foglare.com/v1/messages \
  -H "Content-Type: application/json" \
  -d '{"model":"auto:fast","max_tokens":1024,"stream":true,"messages":[{"role":"user","content":"Hello"}]}'

Responses

POST /v1/responses, OpenAI Responses format. This is the wire Codex CLI speaks. Without stream:true it returns one JSON response object; with it, a named-event SSE stream. Same tiers and model ids.

Field Type Default Notes
modelstringrequiredTier or direct id.
inputstring or arrayrequiredPlain text, or items with role/content. Text parts only; images are dropped.
instructionsstringnonePrepended as a system message.
max_output_tokensintegerupstreamForwarded as max_tokens.
temperaturenumberupstreamForwarded when set.
streamboolfalsefalse returns one JSON object.
reasoning.effortstringnoneMaps to reasoning_effort.
previous_response_idstringnoneAffinity echo, same fglr_ ids.
storebooltrueAccepted, no effect. Responses are not retrievable by id, but all prompt and response content is logged per Data retention.

curl

curl -N https://api.foglare.com/v1/responses \
  -H "Content-Type: application/json" \
  -d '{"model":"auto:fast","input":"Hello","stream":true}'

SSE event order (stream:true)

event: response.created
event: response.output_item.added
event: response.content_part.added
event: response.output_text.delta   (one per text chunk, "delta" carries the text)
event: response.output_text.done
event: response.content_part.done
event: response.output_item.done
event: response.completed           (final response object with usage)

Read the text from response.output_text.delta events. An upstream failure mid-generation ends the stream with response.failed carrying the partial text and an error message, instead of a silent truncation.

Model discovery

GET /v1/models lists every accepted model id in OpenAI catalog format: concrete models alphabetically, then the five auto:* tier aliases. Anonymous, ids only. Health, providers and pricing live in /api/models.

GET /v1/models (trimmed)

{
  "object": "list",
  "data": [
    { "id": "qwen4-max", "object": "model", "created": 1763769600, "owned_by": "foglare" },
    { "id": "auto:fast", "object": "model", "created": 1763769600, "owned_by": "foglare" }
  ]
}

GET /v1/models/:id returns one object with the same fields, or 404:

404 body

{
  "error": {
    "message": "The model 'gpt-9' does not exist. See /v1/models for available models.",
    "type": "invalid_request_error",
    "param": "model",
    "code": "model_not_found"
  }
}

Add ?format=anthropic to either route for the Anthropic SDK shape:

GET /v1/models?format=anthropic (trimmed)

{
  "data": [
    { "id": "qwen4-max", "type": "model", "display_name": "Qwen4 Max", "created_at": "2025-11-22T00:00:00Z" },
    { "id": "auto:fast", "type": "model", "display_name": "Auto Fast", "created_at": "2025-11-22T00:00:00Z" }
  ],
  "has_more": false,
  "first_id": "qwen4-max",
  "last_id": "auto:fast"
}

created is a fixed launch timestamp, 2025-11-22. SDKs require the field; nothing keys off its value.

Provider pinning and affinity

Each model runs on a pool of providers identified by codename, listed per model on the models page. Send provider to keep one request on one provider. A per-request pin wins over your saved pin. Save a pin from the dashboard or models page while signed in to apply it to every browser-session request until you change it.

One-request pin

{
  "model": "qwen4-max",
  "provider": "sigma",
  "messages": [{ "role": "user", "content": "Hello" }]
}

Every response carries an opaque id. Echo it as previous_response_id on the next request to stay on the same provider, which keeps prefix-cache locality for a conversation. Works on all three inference endpoints.

Affinity echo

{
  "model": "auto:fast",
  "previous_response_id": "fglr_...",
  "messages": [{ "role": "user", "content": "Continue where we left off." }]
}

Streaming and errors

Read each data: line as JSON. Append choices[0].delta.content (OpenAI chat) or the text_delta text (Anthropic). If an upstream fails mid-generation, the gateway emits a terminal error chunk with finish_reason: "error" rather than silently truncating, then closes the stream.

Mid-stream error chunk

data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"\n\n[Foglare Error: upstream disconnected mid-generation]"},"finish_reason":"error"}]}
data: [DONE]

Requests that fail before a stream opens return a JSON error body with one of these statuses:

Status Meaning
400Malformed body, or content rejected as random noise. Send natural language.
404Unknown model, or no capacity configured for it. Check GET /v1/models.
503All upstream capacity exhausted, or your linked capacity rate-limited. The message says which, and when to retry.

Chat and messages errors are {"error": "..."}. Responses errors use the OpenAI shape {"error": {"message", "type", "param", "code"}}.

Rate limits

Foglare imposes no rate limits of its own. Upstream provider limits apply and are honored: when an upstream answers 429 with a Retry-After window, the gateway respects that window and routes around the provider. If every route is unavailable you receive a 503; retry after the indicated window.

Public catalog

GET /api/models is public and needs no sign-in. It returns the routing tiers and every served model with status, reasoning levels, uptime, latency and provider codenames. Status is operational, degraded or down; history holds half-hour buckets of ok/fail counts from real traffic.

Example response (trimmed)

{
  "tiers": [
    { "id": "auto:fast", "name": "Fast", "description": "Lowest time to first token across all sizes." }
  ],
  "models": [
    {
      "id": "qwen4-max",
      "name": "Qwen4 Max",
      "tier": "XL",
      "status": "operational",
      "reasoning_levels": ["low", "high", "xhigh"],
      "uptime_24h": 0.99,
      "uptime_7d": 0.98,
      "latency_p50_ms": 842,
      "providers": [
        {
          "codename": "sigma",
          "status": "operational",
          "uptime_24h": 0.99,
          "uptime_7d": 0.98,
          "latency_p50_ms": 842,
          "history": [{ "t": 1795309186, "ok": 12, "fail": 0 }]
        }
      ]
    }
  ]
}

Data retention

Foglare logs the full content of every prompt and response, unredacted, and keeps it indefinitely. Nothing is pruned, and logged data may be sold or shared without notification. Upstream providers may also retain what they process under their own policies. Treat every prompt as stored; do not send secrets or personal data. Details in the privacy policy.

Status and uptime

Health is measured from real routed traffic, not synthetic probes. The models page shows live per-model and per-provider status, 24-hour and 7-day uptime, latency and a half-hour history strip. Check it before relying on a model, and use the routing tiers to let the gateway pick healthy capacity for you.