Flux for a custom endpoint or your own code

For tools with a custom provider block, and for your own code over HTTP. Two wire formats, one key.

Set it up

  1. Pick the wire format your tool or code speaks. Each has its own base URL.

    text
    OpenAI-compatible:    https://api.fluxrouter.ai/v1
      chat:       POST /chat/completions
      responses:  POST /responses
      models:     GET  /models
    
    Anthropic-compatible: https://api.fluxrouter.ai/anthropic
      messages:   POST /v1/messages
  2. Send your key on every request. The Anthropic path also accepts x-api-key.

    text
    Authorization: Bearer sk-YOUR-FLUX-KEY
    x-api-key: sk-YOUR-FLUX-KEY     (Anthropic path only)
  3. Set the model to flux-auto and Flux picks the model for each request, or name a lane or a model to pin it.

Worked examples

A first request

  1. This is the request your code sends.

    text
    POST https://api.fluxrouter.ai/v1/chat/completions
    Authorization: Bearer sk-YOUR-FLUX-KEY
    Content-Type: application/json
    
    {"model": "flux-auto", "messages": [{"role": "user", "content": "Reply with the word ready."}]}

Check the first call

  1. Send the request above. A JSON reply with a message means your key works and Flux is routing.

  2. Open Activity in your Flux account to see the call counted against the model that answered and the key that made it.

What your tool gets

What your tool gets through Flux
AbilityTodayHow it reaches your tool
Every major modelLiveAutomatic, through the base URL.
Read a web pageLiveAdd the Flux tools server (below).
Search the webRolling outSwitched on and being checked. Not promised yet.
Make imagesLiveAdd the Flux tools server (below).
SpeakRolling outSwitched on and being checked. Not promised yet.
Transcribe audioNot in agents yetLive on the API for your own code. No agent reaches it yet.
Act in your appsShippingNot live yet. It is on the way.
MemoryShippingNot live yet. It is on the way.
Second opinionRolling outSwitched on and being checked. Not promised yet.

Statuses come from the same record as the abilities on the homepage, so they change everywhere at once.

Add the Flux tools server

Page reading and image making reach a tool through the Flux tools server, an MCP server on the same key. Web search joins it once it is live.

  1. If your tool can add a remote MCP server with a header, add the Flux tools server. Most tools use this shape; check your tool’s docs for the file it reads.

    json
    {
      "mcpServers": {
        "flux-tools": {
          "url": "https://api.fluxrouter.ai/mcp-tools/",
          "headers": {
            "Authorization": "Bearer sk-YOUR-FLUX-KEY"
          }
        }
      }
    }

Good to know

  • flux-auto bills at the Standard rate, or the Fast rate when it sends your request to the Fast lane and a Fast model answers. Never more than Standard. Pin a model and you pay that model’s rate instead.
  • Flux can pick a different model from one request to the next. A prompt cache belongs to one model, so a switch can mean a cache miss. If a long session leans on caching, pin a model.
  • The Flux tools server needs a funded key. Without one, its tools return an error instead of a result.

If it won’t connect

404 on a path you expected to exist.
Check the base URL matches the wire format. There is no bare /chat path, and an Anthropic client given a base ending in /v1 asks for /v1/v1/messages.
Every request comes back 401.
The key is missing or mistyped, or an old provider key is still set and wins. Paste your Flux key again and remove the other key.
The reply is cut short, or the call times out.
Raise max_tokens for long answers, and allow a longer timeout for reasoning models. Retry 429 and 5xx answers with backoff.

More fixes: my tool won’t connect.