fx-openai
August 19, 2026 ยท View on GitHub
A fork of vercel-labs/fx with OpenAI-compatible API support.
Use any OpenAI-compatible endpoint (OpenAI, OpenRouter, Ollama, LiteLLM, local proxies, etc.) instead of being locked to Vercel AI Gateway.
Quick start
curl -fsSL https://fx.sh/setup.sh | bash # or build from source below
export OPENAI_API_KEY="your-api-key"
export FX_OPENAI_BASE_URL="https://api.openai.com/v1" # optional; this is the default
fx models # fetches models from {base}/models
fx ask "hello" # uses {base}/chat/completions
Custom endpoints
# OpenRouter
export OPENAI_API_KEY="sk-or-..."
export FX_OPENAI_BASE_URL="https://openrouter.ai/api/v1"
# Ollama (OpenAI-compatible)
export OPENAI_API_KEY="ollama"
export FX_OPENAI_BASE_URL="http://127.0.0.1:11434/v1"
# Any compatible proxy
export OPENAI_API_KEY="your-key"
export FX_OPENAI_BASE_URL="https://your-proxy.example/v1"
You can also use FX_OPENAI_API_KEY instead of OPENAI_API_KEY.
Set a model explicitly when your provider uses plain model IDs (not provider/model Gateway IDs):
export FX_MODEL="gpt-4o"
fx ask "Summarize this repo"
How it works
When OPENAI_API_KEY (or FX_OPENAI_API_KEY) is set, fx-openai:
- Authenticates with your OpenAI-compatible API key (takes precedence over Vercel Gateway login)
- Lists models via
GET {FX_OPENAI_BASE_URL}/models - Runs the agent via
POST {FX_OPENAI_BASE_URL}/chat/completionswith streaming SSE
Vercel AI Gateway mode still works when no OpenAI key is configured (fx login, AI_GATEWAY_API_KEY, etc.).
Build from source
Requires Zig 0.16.0+:
git clone https://github.com/iamdemetris/fx-openai.git
cd fx-openai
zig build -Doptimize=ReleaseSafe
./zig-out/bin/fx status
Environment variables
| Variable | Purpose |
|---|---|
OPENAI_API_KEY | API key for OpenAI-compatible providers |
FX_OPENAI_API_KEY | Alias for OPENAI_API_KEY |
FX_OPENAI_BASE_URL | Base URL (default: https://api.openai.com/v1) |
FX_MODEL | Override the model for one run |
All other fx settings and commands work as upstream.
Upstream
Based on vercel-labs/fx (Apache-2.0).
Changes in this fork:
- OpenAI-compatible provider mode (
src/core/config/openai_config.zig,src/core/gateway/openai_json.zig,src/gateway/openai_client.zig) - Custom remote endpoint support when OpenAI mode is active
- Model catalog fetch from
/v1/models
License
Apache-2.0 โ see LICENSE.