TokenFlux Docs

API overview

Base URL, authentication, supported endpoints, streaming and errors of the TokenFlux API

The TokenFlux API is an OpenAI-compatible gateway to many models. Your agents use the same gateway. One account and one balance pay for both.

Base URL and authentication

https://tokenflux.ai/v1

Create a key on API keys and send it as a Bearer token:

Authorization: Bearer YOUR_TOKENFLUX_KEY

Most SDKs need only the base URL and the key. Existing integrations can keep the base URLs https://api.tokenflux.ai/openai/v1 and https://api.tokenflux.ai/anthropic/v1; they reach the same endpoints.

Endpoints

EndpointCompatible with
GET /v1/modelsOpenAI model list
POST /v1/chat/completionsOpenAI Chat Completions
POST /v1/responsesOpenAI Responses
POST /v1/messagesAnthropic Messages
POST /v1/embeddingsOpenAI Embeddings

These are the documented endpoints. Do not depend on other paths.

Models

Use a model ID from GET /v1/models or from Models & pricing. The models a key can call depend on its access, so list them with the key you use.

Not every model supports every endpoint. A model's detail on Models & pricing lists the protocols it supports. When a request reaches a model through a different protocol, TokenFlux converts the request. Chat Completions and Responses convert well. Other conversions can lose provider-specific features, such as thinking signatures, cache_control or hosted tools. For those features, call the endpoint that the model supports natively.

Streaming

Set stream to true to receive server-sent events in the format of the compatible API. Closing the connection cancels the request.

Errors

Errors use the JSON error format of the compatible API with an HTTP error status. If TokenFlux cannot reach the model service, it returns HTTP 502 with this body:

{ "message": "Service temporarily unavailable" }

Retry 429 and 5xx errors with backoff. Fix the request, the key or the balance before you retry another 4xx error.

Billing

Each request is billed to the key's account at the prices on Models & pricing. Usage lists each request with its model, key, tokens and cost.

On this page