docs: add API-key mTLS HTTP client recipes - #3552
Open
jbeckwith-oai wants to merge 4 commits into
Open
Conversation
HAYDEN-OAI
approved these changes
Jul 30, 2026
HAYDEN-OAI
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the mTLS recipe end to end against the SDK custom-client seam and HTTPX/HTTPX2 transport behavior. The approach is sound; I left two low-priority documentation/example comments.
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.
Summary
ssl.SSLContextconfiguration and the existing customhttp_clientseamWhy
Python already supports client certificates through
SSLContext.load_cert_chain(), and both supported HTTP client implementations accept that context throughverify=. This provides a small, language-native mTLS path without adding a new SDK API or runtime dependency.Because the SDK cannot infer that an arbitrary custom HTTP client is configured for mTLS, callers select
https://mtls.api.openai.com/v1(or an EU/custom endpoint) explicitly. The examples dedicate the certificate-bearing transport to that origin and disable redirects.User impact
Users can copy tested file-based PEM recipes for synchronous or asynchronous API-key traffic with either HTTPX or HTTPX2. There are no exported API, generated-client, dependency, or lockfile changes.
Validation
rye run pytest -vv -n 0 tests/test_mtls_http_client.py— 4 passed./scripts/lintrye buildrye run python scripts/utils/validate-httpx2-wheel.py./scripts/test— 7,083 passed, 29 skippedScope
This does not add certificate-only X.509 workload identity, token exchange, certificate refresh, or Realtime/WebSocket mTLS.