Repository navigation
feat!: Switch default HTTP client to httpx2 and use OS trust store by default - #3213
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
copybara/1006549935
branch
from
October 27, 2026 04:08
17dd5ca to
4c8b628
Compare
copybara-service
Bot
force-pushed
the
copybara/1006549935
branch
7 times, most recently
from
October 31, 2026 00:34
b357a5d to
5e2b9e6
Compare
copybara-service
Bot
force-pushed
the
copybara/1006549935
branch
3 times, most recently
from
November 3, 2026 06:52
73103e5 to
cf858cf
Compare
copybara-service
Bot
force-pushed
the
copybara/1006549935
branch
from
November 4, 2026 01:27
cf858cf to
ead356e
Compare
… default BREAKING CHANGE: `httpx2` is now the required dependency and default HTTP client instead of `httpx`, and default SSL verification with `httpx2` uses the OS certificate trust store (via `truststore` / `httpx2.create_ssl_context()`) when `SSL_CERT_FILE` and `SSL_CERT_DIR` are not set. To maintain baseline behavior, install `google-genai[httpx]` and set `GOOGLE_GENAI_HTTP_CLIENT=httpx`. Summary of impact: - If your code uses `httpx` or `httpx2` to interact with the SDK, make sure it uses the same package as the active SDK client. - In most cases, updating your code with `import httpx2 as httpx` is sufficient. - The SDK still fully supports both `httpx` and `httpx2`; only the default has changed. - `httpx` is no longer installed by default (use `pip install google-genai[httpx]` to install a compatible version; `google-genai[httpx2]` remains as a no-op extra). - You can set the SDK's default backend with `GOOGLE_GENAI_HTTP_CLIENT` (`httpx` or `httpx2` strictly requires that package; unset or `auto` prefers `httpx2` and falls back to `httpx` if only `httpx` is installed). - Regardless of the default, passing `HttpOptions(httpx_client=..., httpx_async_client=...)` uses those objects directly (sync and async are configured independently). Where `httpx`/`httpx2` types must match the active client: - `HttpOptions(client_args=..., async_client_args=...)`: package-specific objects such as `Timeout`, `MockTransport` / `BaseTransport` (and `Response` objects from mock handlers), and custom `Auth` subclasses must match the active client. Primitives (numeric timeouts, auth tuples, proxy URL strings) work with either. - Transport exceptions on `client.models`, `files`, etc.: network and timeout errors (`TimeoutException`, `ConnectError`, `HTTPError`) are reraised unwrapped after retries, so `except` clauses catching them directly must match the active client. (4xx/5xx `APIError` exceptions and `client.interactions` `APIConnectionError` / `APITimeoutError` are unchanged, though `.response` / `.request` attributes come from the active client.) Fixes: #2680 PiperOrigin-RevId: 1013424989
copybara-service
Bot
force-pushed
the
copybara/1006549935
branch
from
November 4, 2026 01:43
ead356e to
51285c8
Compare
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.
feat!: Switch default HTTP client to httpx2 and use OS trust store by default
BREAKING CHANGE:
httpx2is now the required dependency and default HTTP clientinstead of
httpx, and default SSL verification withhttpx2uses the OScertificate trust store (via
truststore/httpx2.create_ssl_context()) whenSSL_CERT_FILEandSSL_CERT_DIRare not set. To maintain baseline behavior,install
google-genai[httpx]and setGOOGLE_GENAI_HTTP_CLIENT=httpx.Summary of impact:
httpxorhttpx2to interact with the SDK, make sure ituses the same package as the active SDK client.
import httpx2 as httpxis sufficient.httpxandhttpx2; only the default haschanged.
httpxis no longer installed by default (usepip install google-genai[httpx]to install a compatible version;
google-genai[httpx2]remains as a no-opextra).
GOOGLE_GENAI_HTTP_CLIENT(httpxor
httpx2strictly requires that package; unset orautoprefershttpx2and falls back to
httpxif onlyhttpxis installed).HttpOptions(httpx_client=..., httpx_async_client=...)uses those objects directly (sync and async are configured independently).
Where
httpx/httpx2types must match the active client:HttpOptions(client_args=..., async_client_args=...): package-specific objectssuch as
Timeout,MockTransport/BaseTransport(andResponseobjectsfrom mock handlers), and custom
Authsubclasses must match the active client.Primitives (numeric timeouts, auth tuples, proxy URL strings) work with either.
client.models,files, etc.: network and timeouterrors (
TimeoutException,ConnectError,HTTPError) are reraised unwrappedafter retries, so
exceptclauses catching them directly must match the activeclient. (4xx/5xx
APIErrorexceptions andclient.interactionsAPIConnectionError/APITimeoutErrorare unchanged, though.response/.requestattributes come from the active client.)Fixes: #2680