-
Notifications
You must be signed in to change notification settings - Fork 1.5k
docs: Add Azure, Bedrock and Vertex examples to use Anthropic models #3705
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
base: main
Are you sure you want to change the base?
Conversation
Docs Preview
|
|
|
||
| ### Microsoft Azure | ||
|
|
||
| Azure offers Claude models through their "Models as a Service" using an OpenAI-compatible API. Use [`OpenAIModel`][pydantic_ai.models.openai.OpenAIModel] with an Azure-configured client: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we should be able to use AnthropicModel with AsyncAnthropicFoundry now: https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#api-key-authentication
So let's update these docs to be like the other 3, and then also update this:
| AsyncAnthropicClient: TypeAlias = AsyncAnthropic | AsyncAnthropicBedrock | AsyncAnthropicVertex |
| ```python {title="<a href='/gateway/' style='float: right;'>Learn about Gateway</a>" test="skip"} | ||
| from pydantic_ai import Agent | ||
|
|
||
| agent = Agent('gateway/bedrock:us.anthropic.claude-haiku-4-5-20251001-v1:0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the rest of this page, this will not actually use the AnthropicModel or the Anthropic-API(-running-on-Bedrock), but rather BedrockConverseModel and the AWS Bedrock Converse API (proxied via Gateway of course). Using the Anthropic model will pretty much always give better performance, so I'd prefer to not present this as an equivalent alternative to the AsyncAnthropicBedrock approach. (The little note at the end of the section linking to the bedrock docs is sufficient)
| ```python {title="<a href='/gateway/' style='float: right;'>Learn about Gateway</a>" test="skip"} | ||
| from pydantic_ai import Agent | ||
|
|
||
| agent = Agent('gateway/google-vertex:claude-sonnet-4-5@20250514') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as up; this uses the Google Vertex API, rather than the Anthropic API hosted on Vertex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And let's also have a section pointing out GoogleModel
|
|
||
| bedrock_client = AsyncAnthropicBedrock() # Uses AWS credentials from environment | ||
| provider = AnthropicProvider(anthropic_client=bedrock_client) | ||
| model = AnthropicModel('claude-sonnet-4-5', provider=provider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This model name is wrong! https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock#making-requests
| ``` | ||
|
|
||
| !!! note "Bedrock vs BedrockConverseModel" | ||
| This approach uses Anthropic's SDK with AWS Bedrock credentials. For an alternative using AWS SDK (boto3) directly, see [`BedrockConverseModel`](bedrock.md). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK here I agree it is is worth mentioning the BedrockConverseModel, and then that page will also show the Gateway option.
anthropic.cloud.integrations.mp4