Skip to content

Use different HTTP clients based on providers #1242

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 3 commits into from
Mar 26, 2025

Conversation

Kludex
Copy link
Member

@Kludex Kludex commented Mar 26, 2025

This PR solves the simple test case:

from pydantic_ai import Agent

openai_agent = Agent('openai:gpt-4o-2024-11-20')
vertex_agent = Agent('google-vertex:gemini-1.5-pro')

result = openai_agent.run_sync('Generate a random number between 1 and 100')
print(result.data)

result = vertex_agent.run_sync('Generate a random number between 1 and 100')
print(result.data)

I'm not able to create proper tests with VCR. We need to check that.


This PR uses the same underlying transport, which means the connection pool is shared between providers, but not the client itself - where we do auth, and set the base_url, etc.

This PR also uses a single HTTP client for downloading external resources (e.g. images and documents).


Copy link

github-actions bot commented Mar 26, 2025

Docs Preview

commit: 289da7b
Preview URL: https://a3f36704-pydantic-ai-previews.pydantic.workers.dev

@Kludex Kludex enabled auto-merge (squash) March 26, 2025 11:49
@Kludex Kludex merged commit ec08992 into main Mar 26, 2025
12 checks passed
@Kludex Kludex deleted the use-different-clients-for-each-provider branch March 26, 2025 11:52
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.

Getting 401 request error with open ai service account keys 401 when running Gemini on VertexAI in the Cloud
1 participant