AI Gateway custom providers appear to prepend `/v1` to provider-specific endpoint paths
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 345
- Avg merge
- 13h 31m
- Merged PRs (30d)
- 1
Description
When using an AI Gateway custom provider via the provider-specific endpoint, Gateway appears to prepend `/v1` to the upstream path even when the custom provider `base_url` is configured without `/v1`.
Per the docs, this route:
`https://gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id}/custom-{slug}/{provider-path}`
should map to:
`{base_url}/{provider-path}`
Docs reference:
[Custom Providers ->Provider with a non-standard API path][(https://developers.cloudflare.com/ai-gateway/configuration/custom-providers/#via-provider-specific-endpoint](https://developers.cloudflare.com/ai-gateway/configuration/custom-providers/#example-2-provider-with-a-non-standard-api-path))
In my case, the custom provider is configured as:
- `slug`: `exa-provider`
- `base_url`: `https://api.exa.ai`
So this Gateway request:
`POST .../custom-exa-provider/search`
should go upstream to:
`POST https://api.exa.ai/search`
But the actual upstream behavior looks like:
`POST https://api.exa.ai/v1/search`
## Steps to reproduce
1. Create a custom provider with:
- `slug`: `exa-provider`
- `base_url`: `https://api.exa.ai`
2. Create a provider config / BYOK alias for that provider.
3. Send this request through AI Gateway:
```bash
curl -sS -i -X POST \
"https://gateway.ai.cloudflare.com/v1/${ACCOUNT_ID}/${GATEWAY_ID}/custom-exa-provider/search" \
-H "cf-aig-authorization: Bearer ${AI_GATEWAY_TOKEN}" \
-H "cf-aig-byok-alias: ${BYOK_ALIAS}" \
-H "Content-Type: application/json" \
-d '{"query":"Satya Nadella","category":"people","numResults":2}'
Contributor guide
Research direction
Start by tracing the provider-specific custom route described in the issue and how it combines the configured base_url with the provider path. Reproduce the curl request with a base_url of https://api.exa.ai, then verify that the upstream request uses /search rather than /v1/search.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100