Skip to content

timeout paramter is not respected in openai.ChatCompletion.create method #549

@ivan-shaporov

Description

@ivan-shaporov

Describe the bug

openai.ChatCompletion.create takes timeout parameter but the call might take significantly longer without timing out.

I think it is because of this code:

timeout = kwargs.pop("timeout", None)

while True:
    try:
        return super().create(*args, **kwargs)

Wouldn't it be more consistent overall if you replace pop with get, like this:

timeout = kwargs.get("timeout", None)

To Reproduce

run
openai.ChatCompletion.create(timeout=1, the rest of parameters...)

expected the call either complete under 1 second or fail.

actual: it can take more than 1 second.

Code snippets

No response

OS

Windows 11

Python version

Python 3.9.13

Library version

openai 0.27.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions