Skip to content

Add OpenRouter provider #1778

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 1 commit into from
May 20, 2025
Merged

Add OpenRouter provider #1778

merged 1 commit into from
May 20, 2025

Conversation

Kludex
Copy link
Member

@Kludex Kludex commented May 20, 2025

No description provided.

@Kludex Kludex enabled auto-merge (squash) May 20, 2025 10:24
Copy link
Contributor

hyperlint-ai bot commented May 20, 2025

PR Change Summary

Added support for the OpenRouter provider in the documentation.

  • Replaced OpenAIProvider with OpenRouterProvider in the example code
  • Updated the API key usage to reflect the new provider
  • Modified the documentation to include the OpenRouter integration

Modified Files

  • 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.

Comment on lines +58 to +67
async def test_openrouter_with_google_model(allow_model_requests: None, openrouter_api_key: str) -> None:
provider = OpenRouterProvider(api_key=openrouter_api_key)
model = OpenAIModel('google/gemini-2.0-flash-exp:free', provider=provider)
agent = Agent(model, instructions='Be helpful.')
response = await agent.run('Tell me a joke.')
assert response.output == snapshot("""\
Why don't scientists trust atoms? \n\

Because they make up everything!
""")
Copy link
Member Author

Choose a reason for hiding this comment

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

Supposedly, this would have failed...

@Kludex Kludex merged commit 126710a into main May 20, 2025
17 checks passed
@Kludex Kludex deleted the add-openrouter-provider branch May 20, 2025 10:31
Copy link

Docs Preview

commit: d271079
Preview URL: https://b78f395b-pydantic-ai-previews.pydantic.workers.dev

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.

1 participant