Skip to content

feat: send request timeout header#3351

Open
nightcityblade wants to merge 1 commit into
openai:mainfrom
nightcityblade:fix/issue-3277
Open

feat: send request timeout header#3351
nightcityblade wants to merge 1 commit into
openai:mainfrom
nightcityblade:fix/issue-3277

Conversation

@nightcityblade
Copy link
Copy Markdown

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

Changes being requested

Adds a request-timeout-ms header when a numeric request timeout is configured, allowing downstream services to receive the request wall-clock deadline in milliseconds. The header is not set for httpx.Timeout objects and can be omitted or overridden by callers via extra_headers.

Additional context & links

Fixes #3277

Tests:

  • .venv/bin/ruff check src/openai/_base_client.py tests/test_client.py
  • .venv/bin/python -m pytest -o addopts='' tests/test_client.py

@nightcityblade nightcityblade requested a review from a team as a code owner June 1, 2026 15:28
Copy link
Copy Markdown

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

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: 06be158da8

ℹ️ 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 on lines +461 to +463
if "request-timeout-ms" not in lower_custom_headers:
if not isinstance(timeout, Timeout) and timeout is not None:
headers["request-timeout-ms"] = str(int(timeout * 1000))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve default request-timeout-ms overrides

When a client is configured with default_headers={"request-timeout-ms": "..."} and a numeric timeout, this block still overwrites that caller-supplied default because lower_custom_headers only contains per-request extra_headers, while headers already contains merged default headers. The repo's header behavior allows default_headers to override built-in headers (for example X-Stainless-Lang in tests/test_client.py), so this new automatic header cannot be globally overridden via the same public option unless the caller repeats extra_headers on every request.

Useful? React with 👍 / 👎.

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.

RFC: Proactive Server-Side Cancellation via Request-Timeout-Ms

1 participant