⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@OscarSantosMu
Copy link

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

Description

This PR adds type hints for passing tuple timeouts (indirectly already supported by httpx clients) to the client and request methods, allowing for more granular control over connect, read, write, and pool timeouts without having to manually import httpx.Timeout dependency. These type hints are already present in frameworks like LangChain in their openai-langchain Python package.

Changes

  • Defined TimeoutTypes in src/openai/_types.py to include Tuple[Optional[float], ...].
  • Updated BaseClient, OpenAI, AsyncOpenAI, AzureOpenAI, and AsyncAzureOpenAI to accept TimeoutTypes for the timeout parameter.
  • Updated FinalRequestOptions and make_request_options to support TimeoutTypes.
  • Added tests in tests/test_client.py to verify tuple timeout behavior for both sync and async clients.

Tests

  • Added test_request_timeout_tuple and test_client_timeout_tuple to TestOpenAI.
  • Added test_request_timeout_tuple and test_client_timeout_tuple to TestAsyncOpenAI.
  • Verified that passing a 2-tuple sets connect and read timeouts.
  • Verified that passing a 4-tuple sets connect, read, write, and pool timeouts.

@OscarSantosMu OscarSantosMu requested a review from a team as a code owner January 13, 2026 01:50
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