claude-in-microsoft-foundry changedbuild-with-claude/claude-in-microsoft-foundry
Recorded here
Lines+14added
Lines−30removed
From line
31
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits46to this page, all time
The whole hunk
from line 31, old and new numbered
/
from line 31
3131
3232* An active Azure subscription
3333* Access to the [Foundry portal](https://ai.azure.com/)
34* The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) installed (required for the Entra ID cURL and CLI examples, optional otherwise)
34* The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) installed (required for the Entra ID examples in cURL, CLI, and Ruby, optional otherwise)
3535* An Azure RBAC role that allows you to use the resource, such as **Foundry User** (formerly Azure AI User) or **Cognitive Services User**
3636
3737## Install an SDK
from line 38
3838
3939Anthropic’s [client SDKs](https://platform.claude.com/docs/en/cli-sdks-libraries/overview) support Foundry through a platform-specific package or client class. The examples on this page also show requests with cURL and the `ant` CLI. To set up the CLI, see [CLI quickstart](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/quickstart).
4040
41<Note>
42 Foundry is supported by the C#, Go, Java, PHP, Python, and TypeScript SDKs. Foundry is not currently available in the Ruby SDK.
43</Note>
44
4541<Tabs>
4642 <Tab title="Python">
4743 ```bash
from line 108
112108
113109 <Tab title="Ruby">
114110 ```bash
115 # The Ruby SDK does not yet support Foundry natively (see the Authentication
116 # examples for using the standard Ruby SDK as a workaround)
117111 # Gemfile
118112 gem "anthropic"
119113 ```
from line 347
353347 ```
354348
355349 ```ruby Ruby
356 # The Ruby SDK does not yet support Foundry natively. This example uses the
357 # standard Ruby SDK as a workaround. Pass credentials explicitly: without
358 # them, the client falls back to the ANTHROPIC_API_KEY or
359 # ANTHROPIC_AUTH_TOKEN environment variables and could send a Claude API
360 # credential to your Foundry endpoint. Features that Foundry
361 # does not support fail server-side rather than client-side. For full
362 # Foundry support, use the C#, Go, Java, PHP, Python, or TypeScript SDKs.
363350 require "anthropic"
364351
365 client = Anthropic::Client.new(
366 base_url: "https://example-resource.services.ai.azure.com/anthropic",
367 api_key: ENV.fetch("ANTHROPIC_FOUNDRY_API_KEY")
352 client = Anthropic::FoundryClient.new(
353 api_key: ENV.fetch("ANTHROPIC_FOUNDRY_API_KEY"),
354 resource: "example-resource" # your resource name
368355 )
369356
370357 message = client.messages.create(
from line 585
598585 ```
599586
600587 ```ruby Ruby
601 # The Ruby SDK does not yet support Foundry natively. This example uses the
602 # standard Ruby SDK as a workaround, with a static Entra ID token: automatic
603 # token refresh is not built in, so your application must refresh tokens
604 # itself (they typically expire after 1 hour). Pass credentials explicitly:
605 # without them, the client falls back to the ANTHROPIC_API_KEY or
606 # ANTHROPIC_AUTH_TOKEN environment variables. For full Foundry support, use
607 # the C#, Go, Java, PHP, Python, or TypeScript SDKs.
608588 require "anthropic"
609589
610 # Obtain an Entra ID access token, for example using the Azure CLI:
611 # az account get-access-token --resource https://ai.azure.com \
612 # --query accessToken -o tsv
613 client = Anthropic::Client.new(
614 base_url: "https://example-resource.services.ai.azure.com/anthropic",
615 auth_token: ENV.fetch("AZURE_ACCESS_TOKEN")
590 # Get a Microsoft Entra ID token from the Azure CLI. The client calls this
591 # lambda for every request and retry, so in production, cache the token
592 # until it is close to expiry.
593 token_provider = lambda do
594 `az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv`
595 end
596
597 client = Anthropic::FoundryClient.new(
598 resource: "example-resource", # your resource name
599 azure_ad_token_provider: token_provider
616600 )
617601
618602 message = client.messages.create(
No line in this hunk matches that.