Skip to content

Add base_url to Mistral Provider #1617

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 6 commits into from
May 1, 2025
Merged

Add base_url to Mistral Provider #1617

merged 6 commits into from
May 1, 2025

Conversation

alibeyram
Copy link
Contributor

passing base_url to support mistral models that are hosted somewhere else (e.g. Azure)

I tested this and it works

from pydantic_ai import Agent
from pydantic_ai.models.mistral import MistralModel
from pydantic_ai.providers.mistral import MistralProvider

model = MistralModel(
    "mistral-small-2503",
    provider=MistralProvider(
        api_key=os.environ["AZURE_AI_API_KEY"], base_url=os.environ["AZURE_AI_ENDPOINT"]
    ),
)

agent = Agent(model)

@DouweM
Copy link
Contributor

DouweM commented Apr 30, 2025

@alibeyram Thank you! Can you please address the failing CI check by documenting the new attribute in the docstring? And for consistency with OpenAIModel, update the error logic about passing base_url not being mutually compatible with passing http_client? Finally, this deserves some documentation in the Mistral provider docs, similar to what we have for OpenAI.

@DouweM DouweM marked this pull request as draft April 30, 2025 21:09
@DouweM DouweM self-assigned this Apr 30, 2025
Copy link
Contributor

hyperlint-ai bot commented May 1, 2025

PR Change Summary

Added support for specifying a base URL in the Mistral Provider to accommodate models hosted on external platforms like Azure.

  • Introduced base_url parameter in MistralProvider for external model support
  • Updated example code to demonstrate usage of base_url with Azure
  • Modified documentation to reflect changes in MistralProvider

Modified Files

  • docs/models/mistral.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.

@alibeyram
Copy link
Contributor Author

@DouweM ok I did all of them.

@alibeyram alibeyram marked this pull request as ready for review May 1, 2025 02:49
@DouweM DouweM changed the title adding base_url to Mistral Provider Add base_url to Mistral Provider May 1, 2025
@DouweM DouweM merged commit 54fb56a into pydantic:main May 1, 2025
19 checks passed
@DouweM
Copy link
Contributor

DouweM commented May 1, 2025

@alibeyram Thanks Ali!

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