Developer docs
Fluxio speaks three streaming dialects. Find the protocol your code uses, see the exact events it will receive, then point your client at the API host.
https://api.fluxioapi.comSend your key as Authorization: Bearer (OpenAI format), x-api-key (Anthropic format) or x-goog-api-key (Gemini). All three protocols share one host.
OpenAI format: chat completions over SSE
POST /v1/chat/completions with "stream": true. The reply is a text/event-stream of data: lines, each holding one JSON chunk.
curl https://api.fluxioapi.com/v1/chat/completions --no-buffer \
-H "Authorization: Bearer fio_your_key_here" -H "Content-Type: application/json" \
-d '{"model":"gpt-6.1-sol","stream":true,"messages":[{"role":"user","content":"Hello from the river bank"}]}'
Each chunk carries the next piece of text in choices[0].delta.content; the last chunk before [DONE] holds the token counts:
data: {"choices":[{"index":0,"delta":{"content":"Rivers"}}]}
data: {"choices":[{"index":0,"delta":{"content":" bend"}}]}
data: {"choices":[],"usage":{"prompt_tokens":14,"completion_tokens":2,"prompt_tokens_details":{"cached_tokens":0}}}
data: [DONE]
Fluxio always requests that final usage chunk, even when your request leaves include_usage out or sets it to false.
The Responses API (/v1/responses) streams typed events such as response.output_text.delta and reports usage in response.completed.
Anthropic format: Messages events
POST /v1/messages with "stream": true and an anthropic-version header (Fluxio adds 2023-06-01 when it is missing). Events arrive in this order:
event: message_start
data: {"type":"message_start","message":{"usage":{"input_tokens":25,"cache_read_input_tokens":0,"output_tokens":1}}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Current"}}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":31}}
event: message_stop
Input and cache counts come from message_start; the final output count comes from message_delta.
Claude models are served to the official Claude Code and Claude Desktop clients only, version 2.1.285 or newer — this is an upstream rule. GPT, Gemini and the other families work from any OpenAI-format client or SDK.
Gemini format: native streamGenerateContent
Gemini models stream through their own route. Add alt=sse to receive server-sent events; without it the reply is a JSON array delivered in pieces.
curl "https://api.fluxioapi.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse" --no-buffer \
-H "x-goog-api-key: fio_your_key_here" -H "Content-Type: application/json" \
-d '{"contents":[{"role":"user","parts":[{"text":"Name one river that crosses three countries"}]}]}'
Every chunk includes a running usageMetadata total; the last one decides the charge, and thinking tokens count as output.
Gemini models speak their native protocol only. For streaming call :streamGenerateContent?alt=sse; /v1/chat/completions refuses Gemini ids.
What gets counted, and how
- Every request is billed on the tokens the upstream reports: input, output, cache writes and cache reads, each at its own rate.
- If the upstream reports no usage, the call is billed as 2,000 input plus 2,000 output tokens and marked as estimated.
- Closing a stream early still bills the tokens produced up to that moment.
- Token-counting calls (count_tokens and countTokens) are free.
- HTTP 402 means the balance or the monthly plan behind the key is empty — top up to resume.
Client setup
Claude Code · Claude Desktop
Set the base URL to the API host itself (no /v1), use your key as the auth token, then launch claude.
export ANTHROPIC_BASE_URL=https://api.fluxioapi.com
export ANTHROPIC_AUTH_TOKEN=fio_your_key_here
claude
Codex · OpenAI SDK
OpenAI-format clients take the API host plus /v1 as base URL and your key as API key. Chat requests go to /v1/chat/completions.
export OPENAI_BASE_URL=https://api.fluxioapi.com/v1
export OPENAI_API_KEY=fio_your_key_here
codex
import os, openai
river = openai.OpenAI(base_url="https://api.fluxioapi.com/v1", api_key=os.environ["FLUXIO_KEY"])
reply = river.chat.completions.create(model="gpt-6.1-sol", stream=True,
messages=[{"role": "user", "content": "Describe a waterfall in three lines"}])
for piece in reply:
print(piece.choices[0].delta.content or "", end="", flush=True)
GPT ids to start with: gpt-6.1-sol · gpt-6-astra · gpt-5.6-sol
Gemini CLI
Gemini CLI takes the bare API host (do not append /v1beta) and your key:
export GOOGLE_GEMINI_BASE_URL=https://api.fluxioapi.com
export GEMINI_API_KEY=fio_your_key_here
gemini
Gemini ids: gemini-3.1-pro · gemini-4-argon · gemini-3.8-flash · gemini-2.5-flash