Any OpenAI-compatible client
If your tool lets you set a base URL and an API key, it works with Foglare. Set the base URL to
https://api.foglare.com/v1 and put your Foglare API key
(sk-fog-…, created in the dashboard) in the key field. A key is required.
Prerequisites
- A client that accepts a custom OpenAI base URL. Most SDKs, chat UIs and agent frameworks do.
- Optional: a Foglare API key (
sk-fog-…) from the dashboard for per-key usage stats. Where a key field is mandatory but you have no key, any non-empty placeholder is accepted and runs anonymously. - A model id from
GET /v1/models, or a routing tier such asauto:fast.
Configuration
Tools that read the standard OpenAI environment variables need only this. Typical configuration;
check your tool's docs for the exact variable names and whether it wants the root with or without
/v1.
Environment variables
export OPENAI_BASE_URL="https://api.foglare.com/v1"
export OPENAI_API_KEY="sk-fog-YOUR_KEY" | Setting | Value | Notes |
|---|---|---|
OPENAI_BASE_URL | https://api.foglare.com/v1 | Versioned root. The client appends /chat/completions. |
OPENAI_API_KEY | sk-fog-YOUR_KEY | Your Foglare key from the dashboard. Required for inference. |
model | auto:fast | Or any catalog id. Unknown ids return 404. |
Browser-based tools work signed-in: your session cookie is sent automatically and unlocks saved pins and linked capacity. CLI tools need an API key from the dashboard — anonymous calls are rejected.
Examples
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. 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) process.stdout.write(text);
}
} Both inference endpoints always answer with SSE on the chat and messages wires, so read the response as a stream. Full parameter tables are in the API reference.
Verify
List the accepted model ids, then run the curl example above. Chunk lines ending in
data: [DONE] mean the gateway is reachable and your model id is valid.
List model ids
curl https://api.foglare.com/v1/models Expected response (trimmed)
{
"object": "list",
"data": [
{ "id": "deepseek-v4.1-flash", "object": "model", "created": 1763769600, "owned_by": "foglare" },
{ "id": "qwen4-max", "object": "model", "created": 1763769600, "owned_by": "foglare" },
{ "id": "auto:fast", "object": "model", "created": 1763769600, "owned_by": "foglare" }
]
} Expected chat stream (trimmed)
data: {"id":"fglr_...","object":"chat.completion.chunk","model":"auto:fast","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"fglr_...","object":"chat.completion.chunk","model":"auto:fast","choices":[{"index":0,"delta":{"content":""},"finish_reason":"stop"}]}
data: [DONE] Troubleshooting
| Symptom | Fix |
|---|---|
| 404, model not found | The model id is not in the catalog. List accepted ids with GET /v1/models. Tier ids are auto:fast, auto:S, auto:M, auto:L, auto:XL; direct ids carry no suffix. |
| 404 on the endpoint path | The base URL is wrong for this tool. Check whether it expects the root (https://api.foglare.com) or the versioned root (https://api.foglare.com/v1); the configuration table above says which. |
| 503, capacity exhausted | All upstream routes are busy or rate-limited. The error message says when to retry. Retry after that window, or switch to a routing tier so the gateway picks healthy capacity. |
| Output arrives all at once, or the stream hangs | Something between you and the gateway is buffering SSE. Use curl -N, disable proxy buffering (nginx: proxy_buffering off), and read the response as a stream instead of waiting for the full body. |
| Client rejects the placeholder key | Some clients validate the key format locally. A real sk-fog- key passes; without one try a sk- prefixed placeholder such as sk-foglare. The gateway ignores non-key values either way. |
| Tool wants a non-streaming JSON response | The chat and messages endpoints always stream. Use /v1/responses with stream:false for a single JSON object, if your tool speaks the Responses wire. |