Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Consider enabling HTTP2 by default

オープン
#3,476 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
api

調査の方向性

src/openai/_base_client.py の _DefaultHttpxClient と pyproject.toml の依存関係宣言から始めます。HTTP/2 の有効化で h2 依存関係と既存の custom http_client の動作をどのように扱うべきかを確認します。デフォルトクライアントが HTTP/2 を使用し、HTTP/1.1 へのフォールバックやユーザー指定のクライアントに影響を与えなければ作業完了です。

索引モデルが issue の本文から書いたものです。

説明

sdk-breaking-change
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
  • This is a feature request for the Python library
Describe the feature or improvement you're requesting
Motivation

The OpenAI Python SDK uses httpx as its HTTP client, but HTTP/2 is disabled by default (http2=False in httpx.Client.__init__). This means every SDK user is stuck with HTTP/1.1 unless they manually configure a custom httpx.Client(http2=True) — a detail most users never discover.

Checked against v2.44.0 (latest), the _DefaultHttpxClient (src/openai/_base_client.py:834) still doesn't pass http2=True, and pyproject.toml only declares httpx>=0.23.0, <1 with no [http2] extra:

class _DefaultHttpxClient(httpx.Client):
    def __init__(self, **kwargs: Any) -> None:
        kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
        kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
        kwargs.setdefault("follow_redirects", True)
        super().__init__(**kwargs)  # http2 defaults to False
Proposed Change
class _DefaultHttpxClient(httpx.Client):
    def __init__(self, **kwargs: Any) -> None:
        kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
        kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
        kwargs.setdefault("follow_redirects", True)
+       kwargs.setdefault("http2", True)
        super().__init__(**kwargs)

And optionally add an [http2] extra in pyproject.toml:

[project.optional-dependencies]
http2 = ["httpx[http2]"]
Prior Art
  • Anthropic Python SDK (v0.104.1) already passes http2 through to the httpx transport (_base_client.py:871)
  • httpx has supported HTTP/2 since v0.13 (current declared dep is httpx>=0.23.0)
  • The h2 package is lightweight, pure-Python, and widely used
  • HTTP/2 is supported across all major LLM API providers
Compatibility
  • If the user provides a custom http_client, their configuration takes precedence — no breaking change
  • If the server doesn't support HTTP/2, httpx gracefully downgrades to HTTP/1.1 (this has been handled by httpx for years)
  • Connection limits already set by the SDK are fully compatible with HTTP/2
  • No API changes needed — purely internal client configuration
Why Not Just Document It

Users can already do this manually:

import httpx
from openai import OpenAI
client = OpenAI(http_client=httpx.Client(http2=True))

But most users never find this knob. Making it the default means everyone benefits, especially developers using the SDK for production workloads with high request volumes. The downside is negligible: users who don't have h2 installed would get an ImportError at client construction (easily debuggable), or we mitigate this by making h2 optional and wrapping the import.

Additional context

Many popular LLM API providers already support HTTP/2 (confirmed via ALPN h2):

  • OpenAI (api.openai.com)
  • DeepSeek (api.deepseek.com)
  • Anthropic (api.anthropic.com)
Performance Impact

HTTP/2 brings meaningful improvements, especially for chat completions (frequent, streaming requests):

Metric HTTP/1.1 HTTP/2
TLS handshake ~100ms ~67ms (1-RTT)
Single request ~134ms ~123ms
Header compression ❌ ✅ HPACK
Multiplexing ❌ (6 conn/browser limit) ✅ (1-2 connections)
Connections for 10 requests 10 1-2

The biggest win is connection reuse + multiplexing. In HTTP/1.1, every concurrent or back-to-back request opens a new TCP+TLS handshake. With HTTP/2, a single persistent connection handles multiple concurrent requests — critical for streaming chat.completions.create(stream=True) where the SDK opens many chunks over the same connection. Real-world test on DeepSeek API showed TLS handshake dropping from ~100ms to ~67ms just from HTTP/2's 1-RTT TLS.

主要言語
Python
スター
31.8k
フォーク
7.3k
平均マージ
1日 3時間
マージ済み PR(30日)
131

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openai/openai-python のほかの issue

openai/openai-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。