AI Gateway REST: add /ai/v1/models for third-party model discovery
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 345
- Avg merge
- 13h 31m
- Merged PRs (30d)
- 1
Description
The new REST API at `api.cloudflare.com/client/v4/accounts/{ACCT}/ai/v1/*` has no `/models` endpoint, so there is no way to programmatically enumerate the third-party models available to an account through Unified Billing.
### Current behaviour
```bash
curl -X GET "https://api.cloudflare.com/client/v4/accounts/${ACCT}/ai/v1/models" \
-H "Authorization: Bearer ${CF_API_TOKEN}"
```
```
HTTP 405
{"result":null,"success":false,"errors":[{"code":7001,"message":"GET not supported for requested URI."}],"messages":[]}
```
The existing Workers AI catalogue at `/ai/models/search?task=Text%20Generation` returns 37 entries, all `@cf/*`. It does not include third-party Unified Billing models (`openai/*`, `google/*`, `anthropic/*`, `openrouter/*`, etc.).
### Why this matters
- Admin UIs that let operators pick a model cannot populate the dropdown without hardcoding or trial-and-error inference calls.
- Capability and pricing discovery requires falling back to external sources like models.dev or each provider's own API.
- There is no way to detect which third-party providers have Unified Billing enabled on an account without making a probe request per candidate model.
- OpenAI, OpenRouter, Anthropic, and Google all expose a `/models` GET on their native APIs. AI Gateway is the unification layer but the catalogue is the missing piece.
### Suggested shape
Add `GET /ai/v1/models` returning the union of:
- Workers AI models (the existing `/ai/models/search` set)
- Third-party models whose providers have Unified Billing enabled on the account
Each entry should carry:
- `id` (e.g. `openai/gpt-5.4-mini`, `google/gemini-3-flash`, `@cf/meta/llama-3.3-70b-instruct-fp8-fast`)
- `provider`
- `context_window`
- Pricing per million input/output tokens (and cached input where applicable)
- Capability flags (`function_calling`, `reasoning`, `vision`, `audio`, `streaming`)
Mirroring the shape of `/ai/models/search` would let existing clients reuse parsing logic.
Contributor guide
Research direction
Start by locating the REST API implementation for /ai/v1/* and the existing /ai/models/search endpoint. Compare the current Workers AI catalogue response with the proposed union and identify how account-level Unified Billing providers are represented. Done means GET /ai/v1/models returns the documented model, provider, pricing, and capability fields for enabled third-party and Workers AI models.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100