Skip to content

Conversation

@Kludex
Copy link
Member

@Kludex Kludex commented Nov 3, 2025

No description provided.

Comment on lines 74 to 78
/** @apiTypes: the APIs that the provider supports. Example: ['chat', 'responses'] */
apiTypes: APIType[]
/** @routingGroups: a grouping of APIs that serve the same models.
* @example: ['anthropic'] would route the requests to Anthropic, Bedrock and Vertex AI. */
routingGroups?: string[]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fine on the PAIG side, or not?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll make the production code more complicated, but only a little bit.

Why not change it here to just routingGroup?: string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a logic that needs attention!

@Kludex
Copy link
Member Author

Kludex commented Nov 3, 2025

I need to add a test using routingGroups.

I find it a bit weird that when calling chat completions, we need to set baseUrl=.../chat, and then when chat completions call us, the url is going to be /chat/chat/completions.

@Kludex Kludex requested a review from samuelcolvin November 3, 2025 20:32
Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM.

Comment on lines 74 to 78
/** @apiTypes: the APIs that the provider supports. Example: ['chat', 'responses'] */
apiTypes: APIType[]
/** @routingGroups: a grouping of APIs that serve the same models.
* @example: ['anthropic'] would route the requests to Anthropic, Bedrock and Vertex AI. */
routingGroups?: string[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll make the production code more complicated, but only a little bit.

Why not change it here to just routingGroup?: string?

let providerProxies = apiKeyInfo.providers.filter((p) => p.providerId === provider)
let providerProxies = apiKeyInfo.providers.filter((p) => p.apiTypes.includes(apiType))

const routingGroup = request.headers.get('pydantic-ai-gateway-routing-group')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we can't use a query parameter here? I that would be easier to debug.

Also, I think paig-routing is a better name maybe?

@samuelcolvin samuelcolvin merged commit 922b13e into main Nov 4, 2025
3 checks passed
@samuelcolvin samuelcolvin deleted the add-apiTypes-and-routing-groups branch November 4, 2025 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants