What this adds
A provider abstraction layer that lets ai-cli work without a Vercel AI Gateway key, by supporting OpenRouter, fal.ai, and direct OpenAI as backends.
Motivation
Getting a Vercel AI Gateway key requires a Vercel account. Many users already have OpenRouter or OpenAI API keys. This change lets them use ai-cli immediately with what they have.
How it works
Auto-detects the active backend from environment variables. Vercel AI Gateway remains the default — existing behaviour is unchanged.
| Env vars set | Text | Image | Video |
|---|---|---|---|
AI_GATEWAY_API_KEY | ✓ Vercel (100+ models) | ✓ | ✓ |
OPENROUTER_API_KEY | ✓ OpenRouter (300+ models) | — | — |
OPENROUTER_API_KEY + FAL_KEY | ✓ OpenRouter | ✓ fal.ai (Flux, SDXL) | ✓ fal.ai (Kling, Wan, Runway) |
FAL_KEY | — | ✓ fal.ai | ✓ fal.ai |
OPENAI_API_KEY | ✓ GPT models | ✓ DALL-E | — |
AI_PROVIDER=<backend> | explicit override | — | — |
Changes
New file: src/lib/provider.ts
detectBackend()— reads env vars, returns active backendcreateProvider()— returns{ text(), image(), video() }factory functions pointing to the right AI SDK provider
src/lib/models.ts
fetchGatewayModels(backend)— fetches models from the right source- OpenRouter: live from
openrouter.ai/api/v1/models - fal.ai: static catalogue (Flux, Kling, Wan, HunyuanVideo, Runway Gen3) — fal.ai has no public model list endpoint
- OpenAI: static catalogue (GPT-4o, o3, o4-mini, DALL-E 2/3, GPT Image 1)
resolveModels(modality, model, known, backend)— selects correct defaults per backend
src/commands/text.ts, image.ts, video.ts, models.ts
- All commands call
createProvider()and useprovider.text/image/video(modelId) video.tsexits with a clear message if backend has no video supportimage.tslanguage-image path (GPT-4o with image output) is guarded to Vercel gateway only
New dependencies
@openrouter/ai-sdk-providerv2.9.0@ai-sdk/openaiv3.0.58@ai-sdk/falv2.0.33
Testing status
- TypeScript type-checks clean (
tsc --noEmit) - CLI starts and all
--helppages render correctly - Provider package APIs verified at runtime (
fal.image,fal.video,openrouter()all confirmed callable with correct signatures) - End-to-end generation via OpenRouter (not tested with live key — wiring is correct based on package API verification)
- End-to-end generation via fal.ai (not tested with live key — wiring is correct based on package API verification)
- Vercel AI Gateway path: unchanged, all existing tests pass
Happy to add end-to-end tests or adjust the approach based on feedback. If the project prefers to keep the tool Vercel-specific, I understand — just thought this was worth proposing given how often it comes up for first-time users.
Activity
4Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security | Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| npm/@openrouter/ai-sdk-provider@2.9.0 | ||||||
| npm/@ai-sdk/openai@3.0.58 | ||||||
| npm/@ai-sdk/fal@2.0.33 |
@prak-gup is attempting to deploy a commit to the Vercel Labs Team on Vercel.
A member of the Team first needs to authorize it.