Skip to content

Add Vercel AI Gateway provider #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 24, 2025

Conversation

joshualipman123
Copy link
Contributor

Summary

This PR adds support for Vercel AI Gateway as a provider, enabling users to access multiple AI models through Vercel's unified gateway interface.

Usage Example

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.vercel import VercelAIGatewayProvider

# Uses environment variable automatically
model = OpenAIModel(
    'anthropic/claude-4-sonnet',
    provider=VercelAIGatewayProvider(),
)
agent = Agent(model)

# Or pass the API key directly
model = OpenAIModel(
    'anthropic/claude-4-sonnet',
    provider=VercelAIGatewayProvider(api_key='your-vercel-ai-gateway-api-key'),
)
agent = Agent(model)

Copy link
Contributor

hyperlint-ai bot commented Jul 22, 2025

PR Change Summary

Added support for Vercel AI Gateway as a provider, enhancing access to multiple AI models through a unified interface.

  • Introduced Vercel AI Gateway Provider for accessing AI models
  • Updated documentation to include usage examples for the new provider
  • Added instructions for setting up API keys and OIDC tokens

Modified Files

  • docs/api/providers.md
  • docs/models/index.md
  • docs/models/openai.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@joshualipman123
Copy link
Contributor Author

Hey @Kludex @DouweM! I'm an intern at Vercel and have been working on this PR to add support for our AI Gateway as a provider in Pydantic AI. Happy to discuss or answer any questions as helpful!

Copy link
Contributor

@DouweM DouweM left a comment

Choose a reason for hiding this comment

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

@joshualipman123 Thank Joshua, looks good! Can you please resolve the conflicts and the suggestions I made? I also recommend running make format before pushing so we don't run into linter errors in CI.

@DouweM
Copy link
Contributor

DouweM commented Jul 23, 2025

@joshualipman123 FYI, if #2283 merges before this, we'll need to update OpenAIModel in the docs to OpenAIChatCompletionsModel.

@joshualipman123 joshualipman123 force-pushed the add-vercel-ai-gateway-provider branch from eb2de26 to 7232e0b Compare July 23, 2025 16:07
@joshualipman123 joshualipman123 force-pushed the add-vercel-ai-gateway-provider branch from 1b4b56d to 9b930bb Compare July 23, 2025 16:26
@joshualipman123 joshualipman123 force-pushed the add-vercel-ai-gateway-provider branch from 1ca8137 to 54c09ea Compare July 24, 2025 00:07
@joshualipman123 joshualipman123 force-pushed the add-vercel-ai-gateway-provider branch from 32d39fa to bbe1baf Compare July 24, 2025 00:46
@joshualipman123 joshualipman123 requested a review from DouweM July 24, 2025 00:56
@DouweM DouweM enabled auto-merge (squash) July 24, 2025 13:20
@DouweM
Copy link
Contributor

DouweM commented Jul 24, 2025

@joshualipman123 Thanks Josh! I changed to the full name (Vercel AI Gateway) in docs, should merge when CI goes green :)

@DouweM DouweM changed the title Add vercel ai gateway provider Add Vercel AI Gateway provider Jul 24, 2025
@DouweM DouweM disabled auto-merge July 24, 2025 13:21
@DouweM DouweM enabled auto-merge (squash) July 24, 2025 13:21
@DouweM DouweM merged commit 2af4db6 into pydantic:main Jul 24, 2025
17 checks passed
KRRT7 pushed a commit to aseembits93/pydantic-ai that referenced this pull request Jul 24, 2025
Co-authored-by: Douwe Maan <douwe@pydantic.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants