Skip to content

Replace httpx with httpx2 #2680

Closed
Closed

Description

@aosh-ab7e

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is your feature request related to a problem? Please describe.
httpx's Issues, PRs, and Discussions are now restricted to collaborators only — no new submissions are being accepted. Moreover, no stable release has shipped since 0.28.1 (Dec 2024).

Describe the solution you'd like
Replace httpx with httpx2, an active fork by Pydantic.

Describe alternatives you've considered
Keep httpx as-is for compatibility.

Additional context
Closing announcement from the httpx maintainer

Activity

  1. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    priority: p3Desirable enhancement or fix. May not be included in next release.
    on Jul 7, 2026
  2. Venkaiahbabuneelam commented on Jul 7, 2026

    @Venkaiahbabuneelam

    Hi @aosh-ab7e, Thanks for reaching out us!
    Thank you for your feedback. We appreciate you taking the time to share your thoughts with us, and we'll be filing a feature request.
    Thanks

  3. dsfaccini commented on Jul 20, 2026

    @dsfaccini

    For whoever picks up the internal FR: I put together a minimal, runnable demonstration of what it takes to accept an injected httpx2 client — #2747. (httpx2 is Pydantic's actively-maintained, API-compatible fork of httpx; it lives in a separate import namespace, so its classes fail isinstance(x, httpx.*).)

    There are two distinct blockers:

    1. Client rejected at construction. HttpOptions.httpx_async_client / httpx_client are typed via the HttpxClient / HttpxAsyncClient aliases in generated google/genai/types.py; with arbitrary_types_allowed=True, Pydantic emits an is_instance_of(httpx.AsyncClient) check, so HttpOptions(httpx_async_client=httpx2.AsyncClient()) raises ValidationError. Because this is generated code, the durable fix belongs in the generator template.
    2. Response not processed. Hand-written isinstance(x, httpx.Response/Headers) checks and the retry-exception tuple in errors.py / _api_client.py don't recognize httpx2 objects.

    The PR widens both behind a guarded import (a no-op when httpx2 isn't installed) and adds tests proving each blocker with real httpx2 objects. Note the experimental _gaos surfaces (agents / interactions / …) also forward the injected client and would need the same treatment.

    Happy to adjust the shape to whatever fits your generator/templates.

  4. kozlek commented on Jul 23, 2026

    @kozlek

    Hi, thanks for opening the http2 issue !

    Rather than simply allowing httpx2 types, I believe we must go further and replace the default library by httpx2, keeping httpx just as a fallback. httpx should not be installed as required dependency and should not be a mandatory import.

    WDYT ? Happy to discuss about it 🙂

  5. Kludex commented on Aug 2, 2026

    @Kludex
  6. self-assigned this
    on Aug 11, 2026
  7. added a commit that references this issue on Aug 12, 2026
    012804d
  8. removed their assignment
    on Aug 12, 2026
  9. kozlek commented on Aug 12, 2026

    @kozlek

    Thank you for supporting httpx2 clients, but I don't think this is enough. httpx is still is required dependency, and its module is still imported even when httpx2 is used.

    This is not the end goal - the issue title is Replace httpx with httpx2.
    Are you planning to complete the migration in a second step ? Do you need help for that ?
    There is plenty of ways to do it, all of them described in @Kludex migration guide.

  10. Kludex commented on Sep 8, 2026

    @Kludex

    Thanks @kozlek , I've sent your comment to Google's ppl.

  11. 10 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions