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). Text inference uses OpenAI and Anthropic wire formats. Linked Logfare accounts also support media endpoints, including video generation.

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
POST /v1/videos/generations key or session, linked Logfare JSON when complete
GET /v1/models optional JSON list of model ids
GET /v1/models/:id optional JSON model object, or 404
GET /api/models optional 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" \
  -H "Authorization: Bearer sk-fog-YOUR_KEY" \
  -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; the SDK sends it as Authorization: Bearer.
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

// Works from Node or a browser. Outside a signed-in browser session, send your key.
const response = await fetch("https://api.foglare.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk-fog-YOUR_KEY"
  },
  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.

Same call, Anthropic wire: change the path to /v1/messages, add the required max_tokens to the body, and keep the same Authorization: Bearer sk-fog-… header as the quickstart curl above.

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.

Same call, Responses wire: change the path to /v1/responses, send {"model":"auto:fast","input":"Hello","stream":true} as the body, and keep the same Authorization: Bearer sk-fog-… header as the quickstart curl above.

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.

Video generation

POST /v1/videos/generations uses your linked Logfare account. Authenticate with a Foglare API key or a signed-in browser session, then send an exact logfare/<model-id> from your account's model list. The model must be unlocked and list videos/generations in supported_endpoints. Routing tiers and unlinked Foglare model ids do not work here.

Request

Send model and prompt as JSON. Other fields depend on the model and pass through unchanged. Foglare removes only the logfare/ prefix before forwarding the model id. The response is the JSON video result returned by Logfare after generation finishes.

curl

curl https://api.foglare.com/v1/videos/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-fog-YOUR_KEY" \
  -d '{"model":"logfare/YOUR_VIDEO_MODEL","prompt":"A paper boat crosses a puddle.","seconds":4}'

Time limit

Logfare keeps the request open until the video is ready, which can take several minutes. Foglare waits up to 95 seconds for response headers, then returns a sanitized 504. Cloudflare's proxy read timeout is 120 seconds, so a silent longer request can still end in a bare 524 at the edge. The upstream transport also has a 180-second total cap.

This route is synchronous. It returns no job id and offers no status or polling endpoint. Videos that need longer than these limits are not reliable through Foglare. Use Logfare directly for those jobs.

Errors and retention

Foglare does not persist video request or response bodies. Upstream error bodies and redirect locations are never relayed. You receive a JSON error with a safe message and the upstream status for failures such as 403, 404 and 429. Logfare may retain what it processes under its own policies.

Model discovery

GET /v1/models lists Foglare models and tier aliases. Authenticate with a Foglare API key or signed-in session from an account linked to Logfare to also discover its current model ids. Linked ids are private to that account. GET /api/models adds a logfare_models list with live metadata and supported endpoints.

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" }
  ]
}

Use the exact listed logfare/<model-id>. It routes only through your linked account. New and retired models follow Logfare's catalog. A model must be unlocked and list the matching endpoint. If new permissions were enabled after you linked, reconnect your account. Linked text requests use the matching native protocol, including opaque encrypted reasoning and signed thinking blocks. Keep those fields intact when replaying turns. Replay provenance is process-local and expires after six hours. A restart invalidates it, and unknown or cross-account, cross-key, cross-model or cross-protocol replay is rejected.

Field Meaning
endpointsAPIs reported by Logfare.
supported_endpointsThe subset Foglare proxies for this model.
context_length, max_output_tokensLogfare's live limits. Null when Logfare does not report them. Foglare never fills these from a same-named pooled model.
reasoning_levels, default_reasoning_effort, reasoning_mandatorySupported efforts, the default effort and whether reasoning is required.
input_modalities, toolsInput types and tool support reported for chat. Missing values stay null or empty.
access, available, access_noteTier, visibility, opt-in requirements, chat-only and request-limit-exempt flags for your account.

GET /v1/models/:id returns one model or 404. Include the full ID for linked models, including its slashes:

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 routing

Model ids may be prefixed with a provider codename to force routing: sculk/community/qwen4-max runs qwen4-max on the community provider sculk, ignoring pins and session affinity for that request. The split happens on the first /: if the prefix matches an active provider codename (or logfare), that provider serves the request; the rest of the string is the model id.

Auto tags stack: auto:XL:fast filters to the XL tier and then prefers the lowest-latency healthy target within it. Any combination of a size tag (S, M, L, XL) and fast works; an unknown tag is rejected as an unknown model.

Models under community/* are unverified community capacity. They are never auto-routed: request them explicitly, by id or with a provider prefix, when you want them. Reasoning levels are listed per model on the models page.

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

Pooled text endpoints support both modes. With stream: true, read each data: line as JSON and append choices[0].delta.content (OpenAI chat) or the text_delta text (Anthropic). With stream: false or omitted, you get one complete JSON body after generation. Streaming is recommended because some models take more than 30 seconds to first token. Pooled non-streaming requests are capped at 100 seconds. Pooled streaming requests have no total time cap.

Linked Logfare media routes do not use SSE. Video generation waits for the finished video and has separate 95-second, 120-second and 180-second limits described in Video generation.

Function calling passes through: send OpenAI tools / tool_choice (or Anthropic tools with input_schema) and receive tool_calls deltas with finish_reason: "tool_calls" (Anthropic: tool_use blocks, stop_reason: "tool_use"). Replay assistant tool_calls and role: "tool" result messages in history as usual. Browser clients on any origin can call /v1/* directly with a Bearer key (CORS is open on inference routes).

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 needs no sign-in for the pooled catalog. It returns routing tiers and served models with status, reasoning levels, uptime, latency and provider codenames. A signed-in caller with a linked Logfare account also gets the private logfare_models list and Logfare cards labeled as using that account. Linked limits and capabilities come from Logfare, never from a same-named pooled model. 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

Pooled text requests log the full content of every prompt and response, unredacted, and keep it indefinitely. Nothing is pruned, and logged data may be sold or shared without notification. The linked Logfare video route does not persist request or response bodies. Opaque replay provenance stores only hashes in memory, not prompts or reasoning payloads. Upstream providers may retain what they process under their own policies. Treat pooled prompts 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.