OpenAI and Anthropic formats, one endpoint

Whichever SDK your code already speaks, Foglare answers it. Same base URL, same models, two wire formats.

Published by the Foglare team, a four minute read about wire-format compatibility.

The two doors

  • POST /v1/chat/completions
  • OpenAI chat completions format.
  • POST /v1/messages
  • Anthropic messages format.

Base URL

https://api.foglare.com/v1

Both respond with SSE streams.

Two doors, one gateway

Most inference code is written against one of two SDKs: OpenAI's or Anthropic's. Foglare accepts both shapes on the same base URL, so switching a project over is a change of base_url, not a rewrite. The gateway routes either format to the same provider pool and streams the answer back in the format you sent.

The model catalog is shared too: every routing tier and public model id works on both endpoints. You do not pick a format by model, or a model by format.

The OpenAI shape

POST /v1/chat/completions takes model, messages, and optionally stream, temperature, max_tokens, reasoning_effort, provider and previous_response_id.

curl — chat completions

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

Anonymous call, shared pool. In a browser your session cookie rides along automatically.

Swap auto:fast for any tier or public model id from the models page.

The response is a stream of chat.completion.chunk objects. Append choices[0].delta.content from each data: line; the stream ends with data: [DONE].

What the stream looks like

data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Hel"}}]}
data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"lo"}}]}
data: [DONE]

Each data line is one JSON chunk; [DONE] closes the stream.

A mid-stream failure ends with a terminal error chunk, never a silent cut.

The Anthropic shape

POST /v1/messages takes the same fields plus a required max_tokens and an optional system prompt. The tiers and model ids are identical.

curl — messages

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

max_tokens is required on this endpoint; system is optional.

The same provider pins and affinity fields work here too.

The stream emits message_start, then content_block_delta events carrying text_delta, and ends with message_stop.

The event sequence (trimmed)

event: message_start
data: {"type":"message_start","message":{...}}

event: content_block_delta
data: {"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"}}

event: message_stop
data: {"type":"message_stop"}

Append the text_delta text from each content_block_delta event.

What both accept

Beyond the wire shape, the gateway behaves the same on both doors: routing tiers resolve per request, provider pins and previous_response_id affinity work identically, and a mid-stream upstream failure produces a terminal error event rather than a silent truncation. The mechanics are in How routing tiers work.

model
Any routing tier or public model id, on both endpoints.
provider
Optional per-request pin by codename; wins over a saved pin.
previous_response_id
Echo the last response id to stay on the same provider.
reasoning_effort
A level the model accepts — low, medium, high, xhigh, max or minimal; the exact set is reasoning_levels on each model in GET /api/models.
stream
Both endpoints answer with SSE; read the events as they arrive.
max_tokens
Optional on chat completions, required on messages.

Switching a client over

Point your SDK's base URL at https://api.foglare.com/v1 and pass your sk-fog- API key from the dashboard as the api_key argument. Browser requests can instead rely on the session cookie from sign-in. Inference requires one of the two — anonymous calls are rejected.

The docs have complete Python and JavaScript examples for both formats, including stream reading and error handling. The models page lists what you can send in the model field right now.

Python — the only change is the base URL

from openai import OpenAI

client = OpenAI(
    base_url="https://api.foglare.com/v1",
    api_key="unused",
)

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

The api_key is a placeholder the SDK requires; the gateway ignores it.

Read the docs