Bring Your Own Models (Router)
Add your own model providers — Anthropic, OpenAI, OpenRouter, Groq, or any OpenAI-compatible endpoint — and use them in Flexx Agent or from your own code through one router.
What the Router is
Router is flexx's bring-your-own-model gateway. Instead of scattering provider keys across every tool, you add them once, and flexx gives you:
- One place for every model — register any provider and its models appear in your model picker.
- A single endpoint — the router speaks both the OpenAI and Anthropic wire formats, so any SDK works against it unchanged.
- Budgets and allowlists — router keys (
flexxr_…) carry hard daily/monthly spend caps and optional model allowlists, enforced before any upstream call. - Shared history — every conversation is logged (scoped by project) and can be distilled into Memory.
You are not locked into flexx's models
Router is provider-neutral. You can point it at a paid provider, a free gateway, or an OpenAI-compatible endpoint you run yourself. Nothing is required to use Flexx Agent beyond at least one registered model.
Supported providers
| Provider | How it connects | Notes |
|---|---|---|
| Anthropic | Anthropic Messages wire format | Default base URL https://api.anthropic.com |
| OpenAI | OpenAI chat-completions | Default base URL https://api.openai.com/v1 |
| OpenRouter | OpenAI-compatible | Base URL https://openrouter.ai/api/v1 |
| Groq | OpenAI-compatible | Base URL https://api.groq.com/openai/v1 |
| Anthropic-compatible | Anthropic wire format | Any gateway that speaks the Anthropic API — you supply the base URL |
| Custom | OpenAI-compatible | Any OpenAI-compatible endpoint — you supply the base URL |
Most third-party gateways speak the OpenAI format, so the presets cover the common cases. Anything else fits under Custom (OpenAI-compatible).
Add a provider
Everything below happens in the dashboard — Models:
- Open Dashboard → Models and click Connect a provider.
- Pick a provider preset (e.g. OpenRouter) and paste its API key.
- Choose how to name the models:
- Discover models — flexx queries the provider server-side and lists the models your key can reach. Your key never touches the browser beyond the form.
- Enter model ids — type the exact ids you want (useful for gateways that don't expose a model list).
- Register the models you selected.
Your provider key stays server-side
Provider API keys are stored on the server and are never returned to the browser — the dashboard only ever reports whether a key exists. If a model has no key of its own, the router falls back to a key configured for that exact provider.
Pick a default model
After registering models, set a default model for the org. Flexx Agent uses it for new sessions, and you can switch models per session in the model picker.
Use your models in Flexx Agent
Once at least one model is registered, Flexx Agent is ready. Open Flexx Agent, pick a model, and chat — the agent runs every model call through your router, so usage is budgeted and logged. See Flexx Agent.
Use the router from your own code
Because the router speaks both wire formats, any OpenAI or Anthropic SDK can talk to it. Create a router key in Dashboard → Models, then point your client at your router base URL:
# OpenAI-compatible client
OPENAI_BASE_URL=<your-router-base-url>/v1
OPENAI_API_KEY=flexxr_... # a router key from the dashboard
# Anthropic-compatible client
ANTHROPIC_BASE_URL=<your-router-base-url>
ANTHROPIC_API_KEY=flexxr_...| Endpoint | Wire format |
|---|---|
POST /v1/chat/completions | OpenAI chat-completions |
GET /v1/models | OpenAI model list |
POST /v1/messages | Anthropic Messages |
POST /v1/messages/count_tokens | Anthropic token counting |
The base URL is wherever your router is reachable. In the hosted product you
manage models and keys from the dashboard; when self-hosting, the router runs as
its own service (default port 4700) — see Self-Hosting.
Tag traffic with a project scope
Requests can carry x-flexx-project (a git remote) and x-flexx-session headers.
Scoped conversations are what the memory distillation job reads from, so tagging
your traffic means durable facts eventually land in the right project's memory.
Self-hosting: provider keys on the server
When you run the router yourself, you can supply fallback provider keys through environment variables (used only for the provider they belong to):
| Variable | Purpose |
|---|---|
ROUTER_ANTHROPIC_API_KEY | Default key for anthropic models |
ROUTER_OPENAI_API_KEY | Default key for OpenAI's own endpoint |
ROUTER_EXTRA_PROVIDERS | JSON map of named providers → { baseUrl, apiKey, wireFormat } |
A key stored on a model always wins over the environment fallback. A per-model key is required for any non-OpenAI base URL — the router will not send your OpenAI key to a third-party gateway.
Memory
A graph-backed memory layer that gives AI agents durable context across sessions, clients, and machines. Works with a free account and any MCP client — no install required.
Flexx Agent
A unified chat assistant that already has hands (Remote), models (Router), and durable context (Memory) wired together. Bring your own models and your own tools.