Repository navigation
feat: use standard Anthropic clients across SDK samples - #71
Open
Arun Sekhar (achandmsft) wants to merge 1 commit into
Open
Arun Sekhar (achandmsft) wants to merge 1 commit into
Arun Sekhar (achandmsft) wants to merge 1 commit into
Conversation
Use stock SDK clients and generic authentication helpers across seven languages. Preserve Claude Code wiring, add cross-provider configuration checks and regression coverage, and document upstream compatibility requests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Arun Sekhar (achandmsft)
marked this pull request as ready for review
October 29, 2026 16:01
This was referenced Nov 10, 2026
| event_hooks={"request": [authorize]}, | ||
| ) | ||
| # Explicit credentials suppress SDK discovery; the public hook sets the real header. | ||
| return Anthropic( |
Collaborator
There was a problem hiding this comment.
I thought maybe they'd made it easier, per the comment here?
anthropics/anthropic-sdk-python#1496 (comment)
(Though that example uses their own credentials provider)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Use standard Anthropic SDK clients in Python, TypeScript, C#, Go, Java, PHP and Ruby, with small, generic authentication helpers rather than Foundry-specific client dependencies.
Why
Keep application Messages and streaming code portable between Anthropic and Microsoft Foundry. Endpoint, model, authentication source and optional header policy belong in configuration, not a different client type.
This PR is stacked on #70 to keep the SDK migration separate from the pending Industry-attestation change. Merge #70 first, then retarget/rebase this PR onto
main. Because automatic PR runs currently filter tomain, validation was manually dispatched against this SDK head: all 10 Linux jobs passed. After retargeting, dispatch validation again or push an update; changing the base alone does not retrigger this workflow.Related SDK and service requests:
How
TypeScript is intentionally pinned to tested SDK 1.1.0: the configured package feed did not provide 1.3.0 and direct public-registry access failed TLS negotiation in the validation environment. Relevant 1.3.0 source was compared, but that package version was not executed.
Verification
azd upsucceeded end-to-end on a fresh env (Bicep)azd upsucceeded end-to-end on a fresh env (Terraform)python src/hello_claude.pyreturned a live model responseCloud verification was completed during implementation on 2026-10-28/29: one fresh Bicep environment, Haiku 5.5 model version 2,
eastus2, in an authorized Claude-eligible test subscription. Subscription, tenant, principal, account and resource identifiers are intentionally omitted. All preflight/Industry/RBAC hooks remained enabled.All seven languages passed live Messages, SSE streaming and resource-key authentication with native SDK defaults. Python, TypeScript, C#, Go and Java also passed a configuration-only switch from Azure CLI to Azure Developer CLI credentials. The repository verifier passed its required checks and a Python SDK round trip; its independent Claude Code round trip was deliberately skipped. Terraform was not provisioned for this SDK-only change; neither IaC variant's templates changed.
Native Anthropic endpoint routing is verified through offline recording transports, not a native-account live call. Windows PHP live tests used a trusted CA bundle with TLS verification enabled. No credentials or private deployment data are included in this PR.
Publication-time offline validation (2026-10-29), using the documented runners with machine-local runtime/package-cache configuration:
python -m unittest discover -s tests -vpython -m compileall -q src testspip checksamples/typescriptnpm run build;npm testsamples/gogo vet ./...;go test ./...dotnet test samples\dotnet\AnthropicStandardSdk.sln --configuration Release --no-restoremvn -B -ntp -f samples\java\pom.xml testsamples/phpcomposer test(Composer PHAR invoked through PHP)samples/rubybundle exec ruby test/run.rbwith frozen lockfilegit diff --cached --checkJava validation used JDK 25 with
--release 17; CI uses JDK 21. C# validation targets .NET 8. TypeScript validation used Node 24, PHP used 8.5, and Ruby used 4.0; the implementation-time compatibility runs are documented in the language READMEs.Sonnet 5.5 reviewed the staged publication candidate and found no other significant defects. Its publication recommendation was to exercise Linux CI explicitly for the stacked PR. Executed
gh workflow run validate.yml --repo Azure-Samples/claude --ref feat/portable-anthropic-sdk-clients-20261029: passed, all 10 jobs on commit116f2581eb6ce49844b2d82d364e2edac10a8da0, including the seven SDK paths, both static IaC validation jobs, and shell analysis.Checklist
infra-bicep/andinfra-terraform/(if applicable) — N/A: no IaC template changes