Skip to content

feat: Enable HTTP/2 by default in httpx client#3477

Open
KrisTHL181 wants to merge 2 commits into
openai:mainfrom
KrisTHL181:feat/http2-default
Open

feat: Enable HTTP/2 by default in httpx client#3477
KrisTHL181 wants to merge 2 commits into
openai:mainfrom
KrisTHL181:feat/http2-default

Conversation

@KrisTHL181

Copy link
Copy Markdown

Adds http2=True to both _DefaultHttpxClient and _DefaultAsyncHttpxClient, and provides an [http2] optional dependency extra for httpx[http2].

HTTP/2 offers meaningful performance benefits: connection reuse, multiplexing, HPACK header compression, and 1-RTT TLS handshake. All major LLM API providers (OpenAI, DeepSeek, Anthropic) already support HTTP/2 via ALPN negotiation.

Falls back gracefully to HTTP/1.1 if the server doesn't support h2, or if the h2 package is not installed.

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Enable HTTP/2 by default in the SDK's httpx client for both sync (_DefaultHttpxClient) and async (_DefaultAsyncHttpxClient) clients.

Additional context & links

#3476

Adds http2=True to both _DefaultHttpxClient and _DefaultAsyncHttpxClient,
and provides an [http2] optional dependency extra for httpx[http2].

HTTP/2 offers meaningful performance benefits: connection reuse,
multiplexing, HPACK header compression, and 1-RTT TLS handshake.
All major LLM API providers (OpenAI, DeepSeek, Anthropic) already
support HTTP/2 via ALPN negotiation.

Falls back gracefully to HTTP/1.1 if the server doesn't support h2,
or if the h2 package is not installed.
@KrisTHL181 KrisTHL181 requested a review from a team as a code owner July 8, 2026 14:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7db638f1b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/openai/_base_client.py Outdated
Check if h2 is importable at module level and set _HTTP2_AVAILABLE
accordingly. This lets pip install openai[http2] transparently enable
HTTP/2 without breaking users who don't have h2 installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant