0% found this document useful (0 votes)
11 views61 pages

Pydoc Openai

The document provides an overview of the OpenAI package, detailing its contents, including modules, classes, and exceptions. It highlights key classes such as OpenAIError and its subclasses for handling various API errors. Additionally, it describes the AsyncOpenAI client for asynchronous API interactions, including its initialization and configuration options.

Uploaded by

matiasceau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views61 pages

Pydoc Openai

The document provides an overview of the OpenAI package, detailing its contents, including modules, classes, and exceptions. It highlights key classes such as OpenAIError and its subclasses for handling various API errors. Additionally, it describes the AsyncOpenAI client for asynchronous API interactions, including its initialization and configuration options.

Uploaded by

matiasceau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 61

Help on package openai:

NAME
openai - # File generated from our OpenAPI spec by Stainless. See
CONTRIBUTING.md for details.

PACKAGE CONTENTS
__main__
_base_client
_client
_compat
_constants
_exceptions
_extras (package)
_files
_legacy_response
_models
_module_client
_qs
_resource
_response
_streaming
_types
_utils (package)
_version
cli (package)
lib (package)
pagination
resources (package)
types (package)
version

SUBMODULES
_azure

CLASSES
builtins.Exception(builtins.BaseException)
OpenAIError
APIError
APIConnectionError
APITimeoutError
APIResponseValidationError
APIStatusError
AuthenticationError
BadRequestError
ConflictError
InternalServerError
NotFoundError
PermissionDeniedError
RateLimitError
UnprocessableEntityError
ContentFilterFinishReasonError
LengthFinishReasonError
builtins.dict(builtins.object)
RequestOptions
builtins.object
builtins.NoneType
BaseTransport
NotGiven
Timeout
httpx.AsyncClient(httpx._client.BaseClient)
_DefaultAsyncHttpxClient
httpx.Client(httpx._client.BaseClient)
_DefaultHttpxClient
openai._base_client.AsyncAPIClient(openai._base_client.BaseClient)
AsyncOpenAI
openai._base_client.SyncAPIClient(openai._base_client.BaseClient)
OpenAI
pydantic.main.BaseModel(builtins.object)
BaseModel
typing.Generic(builtins.object)
AsyncStream
Stream

class APIConnectionError(APIError)
| APIConnectionError(*, message: 'str' = 'Connection error.', request:
'httpx.Request') -> 'None'
|
| Method resolution order:
| APIConnectionError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, message: 'str' = 'Connection error.', request:
'httpx.Request') -> 'None' from openai._exceptions.APIConnectionError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class APIError(OpenAIError)
| APIError(message: 'str', request: 'httpx.Request', *, body: 'object |
None') -> 'None'
|
| Method resolution order:
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str', request: 'httpx.Request', *, body: 'object |
None') -> 'None' from openai._exceptions.APIError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'body': 'object | None', 'code': 'Optional[str]', '...
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class APIResponseValidationError(APIError)
| APIResponseValidationError(response: 'httpx.Response', body: 'object |
None', *, message: 'str | None' = None) -> 'None'
|
| Method resolution order:
| APIResponseValidationError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, response: 'httpx.Response', body: 'object | None', *,
message: 'str | None' = None) -> 'None' from
openai._exceptions.APIResponseValidationError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'response': 'httpx.Response', 'status_code': 'int'}
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class APIStatusError(APIError)
| APIStatusError(message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None'
|
| Raised when an API response has a status code of 4xx or 5xx.
|
| Method resolution order:
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'request_id': 'str | None', 'response': 'httpx.Resp...
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class APITimeoutError(APIConnectionError)
| APITimeoutError(request: 'httpx.Request') -> 'None'
|
| Method resolution order:
| APITimeoutError
| APIConnectionError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, request: 'httpx.Request') -> 'None' from
openai._exceptions.APITimeoutError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

AsyncClient = class AsyncOpenAI(openai._base_client.AsyncAPIClient)


| AsyncClient(*, api_key: 'str | None' = None, organization: 'str | None' =
None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' =
2, default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.AsyncClient | None' = None,
_strict_response_validation: 'bool' = False) -> 'None'
|
| Method resolution order:
| AsyncOpenAI
| openai._base_client.AsyncAPIClient
| openai._base_client.BaseClient
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, api_key: 'str | None' = None, organization: 'str | None'
= None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' =
2, default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.AsyncClient | None' = None,
_strict_response_validation: 'bool' = False) -> 'None' from
openai._client.AsyncOpenAI
| Construct a new async openai client instance.
|
| This automatically infers the following arguments from their
corresponding environment variables if they are not provided:
| - `api_key` from `OPENAI_API_KEY`
| - `organization` from `OPENAI_ORG_ID`
| - `project` from `OPENAI_PROJECT_ID`
|
| copy(self, *, api_key: 'str | None' = None, organization: 'str | None' =
None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN, http_client:
'httpx.AsyncClient | None' = None, max_retries: 'int | NotGiven' = NOT_GIVEN,
default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self' from openai._client.AsyncOpenAI
| Create a new client instance re-using the same options given to the
current client with optional overriding.
|
| with_options = copy(self, *, api_key: 'str | None' = None, organization:
'str | None' = None, project: 'str | None' = None, base_url: 'str | httpx.URL |
None' = None, timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN,
http_client: 'httpx.AsyncClient | None' = None, max_retries: 'int | NotGiven' =
NOT_GIVEN, default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| auth_headers
|
| default_headers
|
| qs
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'api_key': 'str', 'audio': 'resources.AsyncAudio', ...
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.AsyncAPIClient:
|
| async __aenter__(self: '_T') -> '_T'
|
| async __aexit__(self, exc_type: 'type[BaseException] | None', exc:
'BaseException | None', exc_tb: 'TracebackType | None') -> 'None'
|
| async close(self) -> 'None'
| Close the underlying HTTPX client.
|
| The client will *not* be usable after this.
|
| async delete(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body
| None' = None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| async get(self, path: 'str', *, cast_to: 'Type[ResponseT]', options:
'RequestOptions' = {}, stream: 'bool' = False, stream_cls: 'type[_AsyncStreamT] |
None' = None) -> 'ResponseT | _AsyncStreamT'
|
| get_api_list(self, path: 'str', *, model: 'Type[_T]', page:
'Type[AsyncPageT]', body: 'Body | None' = None, options: 'RequestOptions' = {},
method: 'str' = 'get') -> 'AsyncPaginator[_T, AsyncPageT]'
|
| is_closed(self) -> 'bool'
|
| async patch(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| async post(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, files: 'RequestFiles | None' = None, options: 'RequestOptions' = {},
stream: 'bool' = False, stream_cls: 'type[_AsyncStreamT] | None' = None) ->
'ResponseT | _AsyncStreamT'
|
| async put(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, files: 'RequestFiles | None' = None, options: 'RequestOptions' = {})
-> 'ResponseT'
|
| async request(self, cast_to: 'Type[ResponseT]', options:
'FinalRequestOptions', *, stream: 'bool' = False, stream_cls: 'type[_AsyncStreamT]
| None' = None, remaining_retries: 'Optional[int]' = None) -> 'ResponseT |
_AsyncStreamT'
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from
openai._base_client.AsyncAPIClient:
|
| __orig_bases__ = (openai._base_client.BaseClient[httpx.AsyncClient, op...
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.BaseClient:
|
| platform_headers(self) -> 'Dict[str, str]'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from openai._base_client.BaseClient:
|
| custom_auth
|
| default_query
|
| user_agent
|
| ----------------------------------------------------------------------
| Data descriptors inherited from openai._base_client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| base_url
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.

class AsyncOpenAI(openai._base_client.AsyncAPIClient)
| AsyncOpenAI(*, api_key: 'str | None' = None, organization: 'str | None' =
None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' =
2, default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.AsyncClient | None' = None,
_strict_response_validation: 'bool' = False) -> 'None'
|
| Method resolution order:
| AsyncOpenAI
| openai._base_client.AsyncAPIClient
| openai._base_client.BaseClient
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, api_key: 'str | None' = None, organization: 'str | None'
= None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' =
2, default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.AsyncClient | None' = None,
_strict_response_validation: 'bool' = False) -> 'None' from
openai._client.AsyncOpenAI
| Construct a new async openai client instance.
|
| This automatically infers the following arguments from their
corresponding environment variables if they are not provided:
| - `api_key` from `OPENAI_API_KEY`
| - `organization` from `OPENAI_ORG_ID`
| - `project` from `OPENAI_PROJECT_ID`
|
| copy(self, *, api_key: 'str | None' = None, organization: 'str | None' =
None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN, http_client:
'httpx.AsyncClient | None' = None, max_retries: 'int | NotGiven' = NOT_GIVEN,
default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self' from openai._client.AsyncOpenAI
| Create a new client instance re-using the same options given to the
current client with optional overriding.
|
| with_options = copy(self, *, api_key: 'str | None' = None, organization:
'str | None' = None, project: 'str | None' = None, base_url: 'str | httpx.URL |
None' = None, timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN,
http_client: 'httpx.AsyncClient | None' = None, max_retries: 'int | NotGiven' =
NOT_GIVEN, default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| auth_headers
|
| default_headers
|
| qs
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'api_key': 'str', 'audio': 'resources.AsyncAudio', ...
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.AsyncAPIClient:
|
| async __aenter__(self: '_T') -> '_T'
|
| async __aexit__(self, exc_type: 'type[BaseException] | None', exc:
'BaseException | None', exc_tb: 'TracebackType | None') -> 'None'
|
| async close(self) -> 'None'
| Close the underlying HTTPX client.
|
| The client will *not* be usable after this.
|
| async delete(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body
| None' = None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| async get(self, path: 'str', *, cast_to: 'Type[ResponseT]', options:
'RequestOptions' = {}, stream: 'bool' = False, stream_cls: 'type[_AsyncStreamT] |
None' = None) -> 'ResponseT | _AsyncStreamT'
|
| get_api_list(self, path: 'str', *, model: 'Type[_T]', page:
'Type[AsyncPageT]', body: 'Body | None' = None, options: 'RequestOptions' = {},
method: 'str' = 'get') -> 'AsyncPaginator[_T, AsyncPageT]'
|
| is_closed(self) -> 'bool'
|
| async patch(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| async post(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, files: 'RequestFiles | None' = None, options: 'RequestOptions' = {},
stream: 'bool' = False, stream_cls: 'type[_AsyncStreamT] | None' = None) ->
'ResponseT | _AsyncStreamT'
|
| async put(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, files: 'RequestFiles | None' = None, options: 'RequestOptions' = {})
-> 'ResponseT'
|
| async request(self, cast_to: 'Type[ResponseT]', options:
'FinalRequestOptions', *, stream: 'bool' = False, stream_cls: 'type[_AsyncStreamT]
| None' = None, remaining_retries: 'Optional[int]' = None) -> 'ResponseT |
_AsyncStreamT'
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from
openai._base_client.AsyncAPIClient:
|
| __orig_bases__ = (openai._base_client.BaseClient[httpx.AsyncClient, op...
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.BaseClient:
|
| platform_headers(self) -> 'Dict[str, str]'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from openai._base_client.BaseClient:
|
| custom_auth
|
| default_query
|
| user_agent
|
| ----------------------------------------------------------------------
| Data descriptors inherited from openai._base_client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| base_url
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.

class AsyncStream(typing.Generic)
| AsyncStream(*, cast_to: 'type[_T]', response: 'httpx.Response', client:
'AsyncOpenAI') -> 'None'
|
| Provides the core interface to iterate over an asynchronous stream
response.
|
| Method resolution order:
| AsyncStream
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| async __aenter__(self) -> 'Self' from openai._streaming.AsyncStream
|
| async __aexit__(self, exc_type: 'type[BaseException] | None', exc:
'BaseException | None', exc_tb: 'TracebackType | None') -> 'None' from
openai._streaming.AsyncStream
|
| async __aiter__(self) -> 'AsyncIterator[_T]' from
openai._streaming.AsyncStream
|
| async __anext__(self) -> '_T' from openai._streaming.AsyncStream
|
| __init__(self, *, cast_to: 'type[_T]', response: 'httpx.Response', client:
'AsyncOpenAI') -> 'None' from openai._streaming.AsyncStream
| Initialize self. See help(type(self)) for accurate signature.
|
| async __stream__(self) -> 'AsyncIterator[_T]' from
openai._streaming.AsyncStream
|
| async close(self) -> 'None' from openai._streaming.AsyncStream
| Close the response and release the connection.
|
| Automatically called if the response body is read to completion.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'_decoder': 'SSEDecoder | SSEBytesDecoder', 'respon...
|
| __orig_bases__ = (typing.Generic[~_T],)
|
| __parameters__ = (~_T,)
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.

class AuthenticationError(APIStatusError)
| AuthenticationError(message: 'str', *, response: 'httpx.Response', body:
'object | None') -> 'None'
|
| Method resolution order:
| AuthenticationError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[401]'}
|
| status_code = 401
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class BadRequestError(APIStatusError)
| BadRequestError(message: 'str', *, response: 'httpx.Response', body:
'object | None') -> 'None'
|
| Method resolution order:
| BadRequestError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[400]'}
|
| status_code = 400
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class BaseModel(pydantic.main.BaseModel)
| BaseModel(**data: 'Any') -> 'None'
|
| Method resolution order:
| BaseModel
| pydantic.main.BaseModel
| builtins.object
|
| Methods defined here:
|
| __str__(self) -> 'str' from openai._models.BaseModel
| Return str(self).
|
| to_dict(self, *, mode: "Literal['json', 'python']" = 'python',
use_api_names: 'bool' = True, exclude_unset: 'bool' = True, exclude_defaults:
'bool' = False, exclude_none: 'bool' = False, warnings: 'bool' = True) ->
'dict[str, object]' from openai._models.BaseModel
| Recursively generate a dictionary representation of the model,
optionally specifying which fields to include or exclude.
|
| By default, fields that were not set by the API will not be included,
| and keys will match the API response, *not* the property names from the
model.
|
| For example, if the API responds with `"fooBar": true` but we've
defined a `foo_bar: bool` property,
| the output will use the `"fooBar"` key (unless `use_api_names=False` is
passed).
|
| Args:
| mode:
| If mode is 'json', the dictionary will only contain JSON
serializable types. e.g. `datetime` will be turned into a string, `"2024-3-
22T18:11:19.117000Z"`.
| If mode is 'python', the dictionary may contain any Python
objects. e.g. `datetime(2024, 3, 22)`
|
| use_api_names: Whether to use the key that the API responded with
or the property name. Defaults to `True`.
| exclude_unset: Whether to exclude fields that have not been
explicitly set.
| exclude_defaults: Whether to exclude fields that are set to their
default value from the output.
| exclude_none: Whether to exclude fields that have a value of `None`
from the output.
| warnings: Whether to log warnings when invalid fields are
encountered. This is only supported in Pydantic v2.
|
| to_json(self, *, indent: 'int | None' = 2, use_api_names: 'bool' = True,
exclude_unset: 'bool' = True, exclude_defaults: 'bool' = False, exclude_none:
'bool' = False, warnings: 'bool' = True) -> 'str' from openai._models.BaseModel
| Generates a JSON string representing this model as it would be received
from or sent to the API (but with indentation).
|
| By default, fields that were not set by the API will not be included,
| and keys will match the API response, *not* the property names from the
model.
|
| For example, if the API responds with `"fooBar": true` but we've
defined a `foo_bar: bool` property,
| the output will use the `"fooBar"` key (unless `use_api_names=False` is
passed).
|
| Args:
| indent: Indentation to use in the JSON output. If `None` is passed,
the output will be compact. Defaults to `2`
| use_api_names: Whether to use the key that the API responded with
or the property name. Defaults to `True`.
| exclude_unset: Whether to exclude fields that have not been
explicitly set.
| exclude_defaults: Whether to exclude fields that have the default
value.
| exclude_none: Whether to exclude fields that have a value of
`None`.
| warnings: Whether to show any warnings that occurred during
serialization. This is only supported in Pydantic v2.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| construct(_fields_set: 'set[str] | None' = None, **values: 'object') ->
'ModelT' from openai._models.BaseModel
| # Override the 'construct' method in a way that supports recursive
parsing without validation.
| # Based on
https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
|
| model_construct = construct(_fields_set: 'set[str] | None' = None,
**values: 'object') -> 'ModelT' from openai._models.BaseModel
| # Override the 'construct' method in a way that supports recursive
parsing without validation.
| # Based on
https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {'model_config': 'ClassVar[ConfigDict]'}
|
| __class_vars__ = set()
|
| __private_attributes__ = {}
|
| __pydantic_complete__ = True
|
| __pydantic_core_schema__ = {'cls': <class 'openai.BaseModel'>, 'config...
|
| __pydantic_custom_init__ = False
|
| __pydantic_decorators__ = DecoratorInfos(validators={}, field_validato...
|
| __pydantic_generic_metadata__ = {'args': (), 'origin': None, 'paramete...
|
| __pydantic_parent_namespace__ = {'object': <pydantic._internal._model_...
|
| __pydantic_post_init__ = None
|
| __pydantic_serializer__ = SchemaSerializer(serializer=Model(
| Model...
|
| __pydantic_validator__ = SchemaValidator(title="BaseModel", validator=...
|
| model_computed_fields = {}
|
| model_config = {'defer_build': True, 'extra': 'allow'}
|
| model_fields = {}
|
| ----------------------------------------------------------------------
| Methods inherited from pydantic.main.BaseModel:
|
| __copy__(self) -> 'Self'
| Returns a shallow copy of the model.
|
| __deepcopy__(self, memo: 'dict[int, Any] | None' = None) -> 'Self'
| Returns a deep copy of the model.
|
| __delattr__(self, item: 'str') -> 'Any'
| Implement delattr(self, name).
|
| __eq__(self, other: 'Any') -> 'bool'
| Return self==value.
|
| __getattr__(self, item: 'str') -> 'Any'
|
| __getstate__(self) -> 'dict[Any, Any]'
| Helper for pickle.
|
| __init__(self, /, **data: 'Any') -> 'None'
| Create a new model by parsing and validating input data from keyword
arguments.
|
| Raises [`ValidationError`][pydantic_core.ValidationError] if the input
data cannot be
| validated to form a valid model.
|
| `self` is explicitly positional-only to allow `self` as a field name.
|
| __iter__(self) -> 'TupleGenerator'
| So `dict(model)` works.
|
| __pretty__(self, fmt: 'typing.Callable[[Any], Any]', **kwargs: 'Any') ->
'typing.Generator[Any, None, None]' from pydantic._internal._repr.Representation
| Used by devtools (https://python-devtools.helpmanual.io/) to pretty
print objects.
|
| __repr__(self) -> 'str'
| Return repr(self).
|
| __repr_args__(self) -> '_repr.ReprArgs'
|
| __repr_name__(self) -> 'str' from pydantic._internal._repr.Representation
| Name of the instance's class, used in __repr__.
|
| __repr_str__(self, join_str: 'str') -> 'str' from
pydantic._internal._repr.Representation
|
| __rich_repr__(self) -> 'RichReprResult' from
pydantic._internal._repr.Representation
| Used by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to
pretty print objects.
|
| __setattr__(self, name: 'str', value: 'Any') -> 'None'
| Implement setattr(self, name, value).
|
| __setstate__(self, state: 'dict[Any, Any]') -> 'None'
|
| copy(self, *, include: 'AbstractSetIntStr | MappingIntStrAny | None' =
None, exclude: 'AbstractSetIntStr | MappingIntStrAny | None' = None, update:
'Dict[str, Any] | None' = None, deep: 'bool' = False) -> 'Self'
| Returns a copy of the model.
|
| !!! warning "Deprecated"
| This method is now deprecated; use `model_copy` instead.
|
| If you need `include` or `exclude`, use:
|
| ```py
| data = self.model_dump(include=include, exclude=exclude,
round_trip=True)
| data = {**data, **(update or {})}
| copied = self.model_validate(data)
| ```
|
| Args:
| include: Optional set or mapping specifying which fields to include
in the copied model.
| exclude: Optional set or mapping specifying which fields to exclude
in the copied model.
| update: Optional dictionary of field-value pairs to override field
values in the copied model.
| deep: If True, the values of fields that are Pydantic models will
be deep-copied.
|
| Returns:
| A copy of the model with included, excluded and updated fields as
specified.
|
| dict(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' =
None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults:
'bool' = False, exclude_none: 'bool' = False) -> 'Dict[str, Any]'
|
| json(self, *, include: 'IncEx | None' = None, exclude: 'IncEx | None' =
None, by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults:
'bool' = False, exclude_none: 'bool' = False, encoder: 'Callable[[Any], Any] |
None' = PydanticUndefined, models_as_dict: 'bool' = PydanticUndefined,
**dumps_kwargs: 'Any') -> 'str'
|
| model_copy(self, *, update: 'dict[str, Any] | None' = None, deep: 'bool' =
False) -> 'Self'
| Usage docs:
https://docs.pydantic.dev/2.9/concepts/serialization/#model_copy
|
| Returns a copy of the model.
|
| Args:
| update: Values to change/add in the new model. Note: the data is
not validated
| before creating the new model. You should trust this data.
| deep: Set to `True` to make a deep copy of the model.
|
| Returns:
| New model instance.
|
| model_dump(self, *, mode: "Literal['json', 'python'] | str" = 'python',
include: 'IncEx | None' = None, exclude: 'IncEx | None' = None, context: 'Any |
None' = None, by_alias: 'bool' = False, exclude_unset: 'bool' = False,
exclude_defaults: 'bool' = False, exclude_none: 'bool' = False, round_trip: 'bool'
= False, warnings: "bool | Literal['none', 'warn', 'error']" = True,
serialize_as_any: 'bool' = False) -> 'dict[str, Any]'
| Usage docs:
https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump
|
| Generate a dictionary representation of the model, optionally
specifying which fields to include or exclude.
|
| Args:
| mode: The mode in which `to_python` should run.
| If mode is 'json', the output will only contain JSON
serializable types.
| If mode is 'python', the output may contain non-JSON-
serializable Python objects.
| include: A set of fields to include in the output.
| exclude: A set of fields to exclude from the output.
| context: Additional context to pass to the serializer.
| by_alias: Whether to use the field's alias in the dictionary key if
defined.
| exclude_unset: Whether to exclude fields that have not been
explicitly set.
| exclude_defaults: Whether to exclude fields that are set to their
default value.
| exclude_none: Whether to exclude fields that have a value of
`None`.
| round_trip: If True, dumped values should be valid as input for
non-idempotent types such as Json[T].
| warnings: How to handle serialization errors. False/"none" ignores
them, True/"warn" logs errors,
| "error" raises a [`PydanticSerializationError`]
[pydantic_core.PydanticSerializationError].
| serialize_as_any: Whether to serialize fields with duck-typing
serialization behavior.
|
| Returns:
| A dictionary representation of the model.
|
| model_dump_json(self, *, indent: 'int | None' = None, include: 'IncEx |
None' = None, exclude: 'IncEx | None' = None, context: 'Any | None' = None,
by_alias: 'bool' = False, exclude_unset: 'bool' = False, exclude_defaults: 'bool' =
False, exclude_none: 'bool' = False, round_trip: 'bool' = False, warnings: "bool |
Literal['none', 'warn', 'error']" = True, serialize_as_any: 'bool' = False) ->
'str'
| Usage docs:
https://docs.pydantic.dev/2.9/concepts/serialization/#modelmodel_dump_json
|
| Generates a JSON representation of the model using Pydantic's `to_json`
method.
|
| Args:
| indent: Indentation to use in the JSON output. If None is passed,
the output will be compact.
| include: Field(s) to include in the JSON output.
| exclude: Field(s) to exclude from the JSON output.
| context: Additional context to pass to the serializer.
| by_alias: Whether to serialize using field aliases.
| exclude_unset: Whether to exclude fields that have not been
explicitly set.
| exclude_defaults: Whether to exclude fields that are set to their
default value.
| exclude_none: Whether to exclude fields that have a value of
`None`.
| round_trip: If True, dumped values should be valid as input for
non-idempotent types such as Json[T].
| warnings: How to handle serialization errors. False/"none" ignores
them, True/"warn" logs errors,
| "error" raises a [`PydanticSerializationError`]
[pydantic_core.PydanticSerializationError].
| serialize_as_any: Whether to serialize fields with duck-typing
serialization behavior.
|
| Returns:
| A JSON string representation of the model.
|
| model_post_init(self, _BaseModel__context: 'Any') -> 'None'
| Override this method to perform additional initialization after
`__init__` and `model_construct`.
| This is useful if you want to do some validation that requires the
entire model to be initialized.
|
| ----------------------------------------------------------------------
| Class methods inherited from pydantic.main.BaseModel:
|
| __class_getitem__(typevar_values: 'type[Any] | tuple[type[Any], ...]') ->
'type[BaseModel] | _forward_ref.PydanticRecursiveRef'
|
| __get_pydantic_core_schema__(source: 'type[BaseModel]', handler:
'GetCoreSchemaHandler', /) -> 'CoreSchema'
| Hook into generating the model's CoreSchema.
|
| Args:
| source: The class we are generating a schema for.
| This will generally be the same as the `cls` argument if this
is a classmethod.
| handler: A callable that calls into Pydantic's internal CoreSchema
generation logic.
|
| Returns:
| A `pydantic-core` `CoreSchema`.
|
| __get_pydantic_json_schema__(core_schema: 'CoreSchema', handler:
'GetJsonSchemaHandler', /) -> 'JsonSchemaValue'
| Hook into generating the model's JSON schema.
|
| Args:
| core_schema: A `pydantic-core` CoreSchema.
| You can ignore this argument and call the handler with a new
CoreSchema,
| wrap this CoreSchema (`{'type': 'nullable', 'schema':
current_schema}`),
| or just call the handler with the original schema.
| handler: Call into Pydantic's internal JSON schema generation.
| This will raise a
`pydantic.errors.PydanticInvalidForJsonSchema` if JSON schema
| generation fails.
| Since this gets called by `BaseModel.model_json_schema` you can
override the
| `schema_generator` argument to that function to change JSON
schema generation globally
| for a type.
|
| Returns:
| A JSON schema, as a Python object.
|
| __pydantic_init_subclass__(**kwargs: 'Any') -> 'None'
| This is intended to behave just like `__init_subclass__`, but is called
by `ModelMetaclass`
| only after the class is actually fully initialized. In particular,
attributes like `model_fields` will
| be present when this is called.
|
| This is necessary because `__init_subclass__` will always be called by
`type.__new__`,
| and it would require a prohibitively large refactor to the
`ModelMetaclass` to ensure that
| `type.__new__` was called in such a manner that the class would already
be sufficiently initialized.
|
| This will receive the same `kwargs` that would be passed to the
standard `__init_subclass__`, namely,
| any kwargs passed to the class definition that aren't used internally
by pydantic.
|
| Args:
| **kwargs: Any keyword arguments passed to the class definition that
aren't used internally
| by pydantic.
|
| from_orm(obj: 'Any') -> 'Self'
|
| model_json_schema(by_alias: 'bool' = True, ref_template: 'str' =
'#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = <class
'pydantic.json_schema.GenerateJsonSchema'>, mode: 'JsonSchemaMode' = 'validation')
-> 'dict[str, Any]'
| Generates a JSON schema for a model class.
|
| Args:
| by_alias: Whether to use attribute aliases or not.
| ref_template: The reference template.
| schema_generator: To override the logic used to generate the JSON
schema, as a subclass of
| `GenerateJsonSchema` with your desired modifications
| mode: The mode in which to generate the schema.
|
| Returns:
| The JSON schema for the given model class.
|
| model_parametrized_name(params: 'tuple[type[Any], ...]') -> 'str'
| Compute the class name for parametrizations of generic classes.
|
| This method can be overridden to achieve a custom naming scheme for
generic BaseModels.
|
| Args:
| params: Tuple of types of the class. Given a generic class
| `Model` with 2 type variables and a concrete model `Model[str,
int]`,
| the value `(str, int)` would be passed to `params`.
|
| Returns:
| String representing the new class where `params` are passed to
`cls` as type variables.
|
| Raises:
| TypeError: Raised when trying to generate concrete names for non-
generic models.
|
| model_rebuild(*, force: 'bool' = False, raise_errors: 'bool' = True,
_parent_namespace_depth: 'int' = 2, _types_namespace: 'dict[str, Any] | None' =
None) -> 'bool | None'
| Try to rebuild the pydantic-core schema for the model.
|
| This may be necessary when one of the annotations is a ForwardRef which
could not be resolved during
| the initial attempt to build the schema, and automatic rebuilding
fails.
|
| Args:
| force: Whether to force the rebuilding of the model schema,
defaults to `False`.
| raise_errors: Whether to raise errors, defaults to `True`.
| _parent_namespace_depth: The depth level of the parent namespace,
defaults to 2.
| _types_namespace: The types namespace, defaults to `None`.
|
| Returns:
| Returns `None` if the schema is already "complete" and rebuilding
was not required.
| If rebuilding _was_ required, returns `True` if rebuilding was
successful, otherwise `False`.
|
| model_validate(obj: 'Any', *, strict: 'bool | None' = None,
from_attributes: 'bool | None' = None, context: 'Any | None' = None) -> 'Self'
| Validate a pydantic model instance.
|
| Args:
| obj: The object to validate.
| strict: Whether to enforce types strictly.
| from_attributes: Whether to extract data from object attributes.
| context: Additional context to pass to the validator.
|
| Raises:
| ValidationError: If the object could not be validated.
|
| Returns:
| The validated model instance.
|
| model_validate_json(json_data: 'str | bytes | bytearray', *, strict: 'bool
| None' = None, context: 'Any | None' = None) -> 'Self'
| Usage docs: https://docs.pydantic.dev/2.9/concepts/json/#json-parsing
|
| Validate the given JSON data against the Pydantic model.
|
| Args:
| json_data: The JSON data to validate.
| strict: Whether to enforce types strictly.
| context: Extra variables to pass to the validator.
|
| Returns:
| The validated Pydantic model.
|
| Raises:
| ValidationError: If `json_data` is not a JSON string or the object
could not be validated.
|
| model_validate_strings(obj: 'Any', *, strict: 'bool | None' = None,
context: 'Any | None' = None) -> 'Self'
| Validate the given object with string data against the Pydantic model.
|
| Args:
| obj: The object containing string data to validate.
| strict: Whether to enforce types strictly.
| context: Extra variables to pass to the validator.
|
| Returns:
| The validated Pydantic model.
|
| parse_file(path: 'str | Path', *, content_type: 'str | None' = None,
encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None,
allow_pickle: 'bool' = False) -> 'Self'
|
| parse_obj(obj: 'Any') -> 'Self'
|
| parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding:
'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle:
'bool' = False) -> 'Self'
|
| schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') ->
'Dict[str, Any]'
|
| schema_json(*, by_alias: 'bool' = True, ref_template: 'str' =
'#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str'
|
| update_forward_refs(**localns: 'Any') -> 'None'
|
| validate(value: 'Any') -> 'Self'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from pydantic.main.BaseModel:
|
| __fields_set__
|
| model_extra
| Get extra fields set during validation.
|
| Returns:
| A dictionary of extra fields, or `None` if `config.extra` is not
set to `"allow"`.
|
| model_fields_set
| Returns the set of fields that have been explicitly set on this model
instance.
|
| Returns:
| A set of strings representing the fields that have been set,
| i.e. that were not filled from defaults.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from pydantic.main.BaseModel:
|
| __dict__
| dictionary for instance variables
|
| __pydantic_extra__
|
| __pydantic_fields_set__
|
| __pydantic_private__
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from pydantic.main.BaseModel:
|
| __hash__ = None
|
| __pydantic_root_model__ = False

Client = class OpenAI(openai._base_client.SyncAPIClient)


| Client(*, api_key: 'str | None' = None, organization: 'str | None' = None,
project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None, timeout:
'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' = 2,
default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.Client | None' = None,
_strict_response_validation: 'bool' = False) -> 'None'
|
| Method resolution order:
| OpenAI
| openai._base_client.SyncAPIClient
| openai._base_client.BaseClient
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, api_key: 'str | None' = None, organization: 'str | None'
= None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' =
2, default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.Client | None' = None,
_strict_response_validation: 'bool' = False) -> 'None' from openai._client.OpenAI
| Construct a new synchronous openai client instance.
|
| This automatically infers the following arguments from their
corresponding environment variables if they are not provided:
| - `api_key` from `OPENAI_API_KEY`
| - `organization` from `OPENAI_ORG_ID`
| - `project` from `OPENAI_PROJECT_ID`
|
| copy(self, *, api_key: 'str | None' = None, organization: 'str | None' =
None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN, http_client:
'httpx.Client | None' = None, max_retries: 'int | NotGiven' = NOT_GIVEN,
default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self' from openai._client.OpenAI
| Create a new client instance re-using the same options given to the
current client with optional overriding.
|
| with_options = copy(self, *, api_key: 'str | None' = None, organization:
'str | None' = None, project: 'str | None' = None, base_url: 'str | httpx.URL |
None' = None, timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN,
http_client: 'httpx.Client | None' = None, max_retries: 'int | NotGiven' =
NOT_GIVEN, default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| auth_headers
|
| default_headers
|
| qs
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'api_key': 'str', 'audio': 'resources.Audio', 'batc...
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.SyncAPIClient:
|
| __enter__(self: '_T') -> '_T'
|
| __exit__(self, exc_type: 'type[BaseException] | None', exc: 'BaseException
| None', exc_tb: 'TracebackType | None') -> 'None'
|
| close(self) -> 'None'
| Close the underlying HTTPX client.
|
| The client will *not* be usable after this.
|
| delete(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| get(self, path: 'str', *, cast_to: 'Type[ResponseT]', options:
'RequestOptions' = {}, stream: 'bool' = False, stream_cls: 'type[_StreamT] | None'
= None) -> 'ResponseT | _StreamT'
|
| get_api_list(self, path: 'str', *, model: 'Type[object]', page:
'Type[SyncPageT]', body: 'Body | None' = None, options: 'RequestOptions' = {},
method: 'str' = 'get') -> 'SyncPageT'
|
| is_closed(self) -> 'bool'
|
| patch(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body | None'
= None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| post(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body | None'
= None, options: 'RequestOptions' = {}, files: 'RequestFiles | None' = None,
stream: 'bool' = False, stream_cls: 'type[_StreamT] | None' = None) -> 'ResponseT |
_StreamT'
|
| put(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body | None' =
None, files: 'RequestFiles | None' = None, options: 'RequestOptions' = {}) ->
'ResponseT'
|
| request(self, cast_to: 'Type[ResponseT]', options: 'FinalRequestOptions',
remaining_retries: 'Optional[int]' = None, *, stream: 'bool' = False, stream_cls:
'type[_StreamT] | None' = None) -> 'ResponseT | _StreamT'
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from openai._base_client.SyncAPIClient:
|
| __orig_bases__ = (openai._base_client.BaseClient[httpx.Client, openai....
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.BaseClient:
|
| platform_headers(self) -> 'Dict[str, str]'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from openai._base_client.BaseClient:
|
| custom_auth
|
| default_query
|
| user_agent
|
| ----------------------------------------------------------------------
| Data descriptors inherited from openai._base_client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| base_url
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.

class ConflictError(APIStatusError)
| ConflictError(message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None'
|
| Method resolution order:
| ConflictError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[409]'}
|
| status_code = 409
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class ContentFilterFinishReasonError(OpenAIError)
| ContentFilterFinishReasonError() -> 'None'
|
| Method resolution order:
| ContentFilterFinishReasonError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self) -> 'None' from
openai._exceptions.ContentFilterFinishReasonError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

DefaultAsyncHttpxClient = class _DefaultAsyncHttpxClient(httpx.AsyncClient)


| DefaultAsyncHttpxClient(**kwargs: 'Any') -> 'None'
|
| Method resolution order:
| _DefaultAsyncHttpxClient
| httpx.AsyncClient
| httpx._client.BaseClient
| builtins.object
|
| Methods defined here:
|
| __init__(self, **kwargs: 'Any') -> 'None' from
openai._base_client._DefaultAsyncHttpxClient
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from httpx.AsyncClient:
|
| async __aenter__(self: 'U') -> 'U' from httpx._client.AsyncClient
|
| async __aexit__(self, exc_type: 'type[BaseException] | None' = None,
exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None)
-> 'None' from httpx._client.AsyncClient
|
| async aclose(self) -> 'None' from httpx._client.AsyncClient
| Close transport and proxies.
|
| async delete(self, url: 'URL | str', *, params: 'QueryParamTypes | None' =
None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None,
auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.AsyncClient
| Send a `DELETE` request.
|
| **Parameters**: See `httpx.request`.
|
| async get(self, url: 'URL | str', *, params: 'QueryParamTypes | None' =
None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None,
auth: 'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.AsyncClient
| Send a `GET` request.
|
| **Parameters**: See `httpx.request`.
|
| async head(self, url: 'URL | str', *, params: 'QueryParamTypes | None' =
None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None,
auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.AsyncClient
| Send a `HEAD` request.
|
| **Parameters**: See `httpx.request`.
|
| async options(self, url: 'URL | str', *, params: 'QueryParamTypes | None' =
None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None,
auth: 'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.AsyncClient
| Send an `OPTIONS` request.
|
| **Parameters**: See `httpx.request`.
|
| async patch(self, url: 'URL | str', *, content: 'RequestContent | None' =
None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json:
'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers:
'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `PATCH` request.
|
| **Parameters**: See `httpx.request`.
|
| async post(self, url: 'URL | str', *, content: 'RequestContent | None' =
None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json:
'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers:
'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `POST` request.
|
| **Parameters**: See `httpx.request`.
|
| async put(self, url: 'URL | str', *, content: 'RequestContent | None' =
None, data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json:
'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers:
'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Response' from httpx._client.AsyncClient
| Send a `PUT` request.
|
| **Parameters**: See `httpx.request`.
|
| async request(self, method: 'str', url: 'URL | str', *, content:
'RequestContent | None' = None, data: 'RequestData | None' = None, files:
'RequestFiles | None' = None, json: 'typing.Any | None' = None, params:
'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies:
'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault | None' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, follow_redirects: 'bool
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
timeout: 'TimeoutTypes | UseClientDefault' = <httpx._client.UseClientDefault object
at 0x726fae87f8c0>, extensions: 'RequestExtensions | None' = None) -> 'Response'
from httpx._client.AsyncClient
| Build and send a request.
|
| Equivalent to:
|
| ```python
| request = client.build_request(...)
| response = await client.send(request, ...)
| ```
|
| See `AsyncClient.build_request()`, `AsyncClient.send()`
| and [Merging of configuration][0] for how the various parameters
| are merged with client-level configuration.
|
| [0]: /advanced/clients/#merging-of-configuration
|
| async send(self, request: 'Request', *, stream: 'bool' = False, auth:
'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>) -> 'Response' from
httpx._client.AsyncClient
| Send a request.
|
| The request is sent as-is, unmodified.
|
| Typically you'll want to build one with `AsyncClient.build_request()`
| so that any client-level configuration is merged into the request,
| but passing an explicit `httpx.Request()` is supported as well.
|
| See also: [Request instances][0]
|
| [0]: /advanced/clients/#request-instances
|
| stream(self, method: 'str', url: 'URL | str', *, content: 'RequestContent |
None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' =
None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'typing.AsyncIterator[Response]'
from httpx._client.AsyncClient
| Alternative to `httpx.request()` that streams the response body
| instead of loading it into memory at once.
|
| **Parameters**: See `httpx.request`.
|
| See also: [Streaming Responses][0]
|
| [0]: /quickstart#streaming-responses
|
| ----------------------------------------------------------------------
| Methods inherited from httpx._client.BaseClient:
|
| build_request(self, method: 'str', url: 'URL | str', *, content:
'RequestContent | None' = None, data: 'RequestData | None' = None, files:
'RequestFiles | None' = None, json: 'typing.Any | None' = None, params:
'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies:
'CookieTypes | None' = None, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Request'
| Build and return a request instance.
|
| * The `params`, `headers` and `cookies` arguments
| are merged with any values set on the client.
| * The `url` argument is merged with any `base_url` set on the client.
|
| See also: [Request instances][0]
|
| [0]: /advanced/clients/#request-instances
|
| ----------------------------------------------------------------------
| Readonly properties inherited from httpx._client.BaseClient:
|
| is_closed
| Check if the client being closed
|
| trust_env
|
| ----------------------------------------------------------------------
| Data descriptors inherited from httpx._client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| auth
| Authentication class used when none is passed at the request-level.
|
| See also [Authentication][0].
|
| [0]: /quickstart/#authentication
|
| base_url
| Base URL to use when sending requests with relative URLs.
|
| cookies
| Cookie values to include when sending requests.
|
| event_hooks
|
| headers
| HTTP headers to include when sending requests.
|
| params
| Query parameters to include in the URL when sending requests.
|
| timeout

DefaultHttpxClient = class _DefaultHttpxClient(httpx.Client)


| DefaultHttpxClient(**kwargs: 'Any') -> 'None'
|
| Method resolution order:
| _DefaultHttpxClient
| httpx.Client
| httpx._client.BaseClient
| builtins.object
|
| Methods defined here:
|
| __init__(self, **kwargs: 'Any') -> 'None' from
openai._base_client._DefaultHttpxClient
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from httpx.Client:
|
| __enter__(self: 'T') -> 'T' from httpx._client.Client
|
| __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value:
'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None'
from httpx._client.Client
|
| close(self) -> 'None' from httpx._client.Client
| Close transport and proxies.
|
| delete(self, url: 'URL | str', *, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.Client
| Send a `DELETE` request.
|
| **Parameters**: See `httpx.request`.
|
| get(self, url: 'URL | str', *, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.Client
| Send a `GET` request.
|
| **Parameters**: See `httpx.request`.
|
| head(self, url: 'URL | str', *, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.Client
| Send a `HEAD` request.
|
| **Parameters**: See `httpx.request`.
|
| options(self, url: 'URL | str', *, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.Client
| Send an `OPTIONS` request.
|
| **Parameters**: See `httpx.request`.
|
| patch(self, url: 'URL | str', *, content: 'RequestContent | None' = None,
data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json:
'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers:
'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `PATCH` request.
|
| **Parameters**: See `httpx.request`.
|
| post(self, url: 'URL | str', *, content: 'RequestContent | None' = None,
data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json:
'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers:
'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `POST` request.
|
| **Parameters**: See `httpx.request`.
|
| put(self, url: 'URL | str', *, content: 'RequestContent | None' = None,
data: 'RequestData | None' = None, files: 'RequestFiles | None' = None, json:
'typing.Any | None' = None, params: 'QueryParamTypes | None' = None, headers:
'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes
| UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
follow_redirects: 'bool | UseClientDefault' = <httpx._client.UseClientDefault
object at 0x726fae87f8c0>, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Response' from httpx._client.Client
| Send a `PUT` request.
|
| **Parameters**: See `httpx.request`.
|
| request(self, method: 'str', url: 'URL | str', *, content: 'RequestContent
| None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' =
None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'Response' from
httpx._client.Client
| Build and send a request.
|
| Equivalent to:
|
| ```python
| request = client.build_request(...)
| response = client.send(request, ...)
| ```
|
| See `Client.build_request()`, `Client.send()` and
| [Merging of configuration][0] for how the various parameters
| are merged with client-level configuration.
|
| [0]: /advanced/clients/#merging-of-configuration
|
| send(self, request: 'Request', *, stream: 'bool' = False, auth: 'AuthTypes
| UseClientDefault | None' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>) -> 'Response' from
httpx._client.Client
| Send a request.
|
| The request is sent as-is, unmodified.
|
| Typically you'll want to build one with `Client.build_request()`
| so that any client-level configuration is merged into the request,
| but passing an explicit `httpx.Request()` is supported as well.
|
| See also: [Request instances][0]
|
| [0]: /advanced/clients/#request-instances
|
| stream(self, method: 'str', url: 'URL | str', *, content: 'RequestContent |
None' = None, data: 'RequestData | None' = None, files: 'RequestFiles | None' =
None, json: 'typing.Any | None' = None, params: 'QueryParamTypes | None' = None,
headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth:
'AuthTypes | UseClientDefault | None' = <httpx._client.UseClientDefault object at
0x726fae87f8c0>, follow_redirects: 'bool | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, timeout: 'TimeoutTypes |
UseClientDefault' = <httpx._client.UseClientDefault object at 0x726fae87f8c0>,
extensions: 'RequestExtensions | None' = None) -> 'typing.Iterator[Response]' from
httpx._client.Client
| Alternative to `httpx.request()` that streams the response body
| instead of loading it into memory at once.
|
| **Parameters**: See `httpx.request`.
|
| See also: [Streaming Responses][0]
|
| [0]: /quickstart#streaming-responses
|
| ----------------------------------------------------------------------
| Methods inherited from httpx._client.BaseClient:
|
| build_request(self, method: 'str', url: 'URL | str', *, content:
'RequestContent | None' = None, data: 'RequestData | None' = None, files:
'RequestFiles | None' = None, json: 'typing.Any | None' = None, params:
'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies:
'CookieTypes | None' = None, timeout: 'TimeoutTypes | UseClientDefault' =
<httpx._client.UseClientDefault object at 0x726fae87f8c0>, extensions:
'RequestExtensions | None' = None) -> 'Request'
| Build and return a request instance.
|
| * The `params`, `headers` and `cookies` arguments
| are merged with any values set on the client.
| * The `url` argument is merged with any `base_url` set on the client.
|
| See also: [Request instances][0]
|
| [0]: /advanced/clients/#request-instances
|
| ----------------------------------------------------------------------
| Readonly properties inherited from httpx._client.BaseClient:
|
| is_closed
| Check if the client being closed
|
| trust_env
|
| ----------------------------------------------------------------------
| Data descriptors inherited from httpx._client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| auth
| Authentication class used when none is passed at the request-level.
|
| See also [Authentication][0].
|
| [0]: /quickstart/#authentication
|
| base_url
| Base URL to use when sending requests with relative URLs.
|
| cookies
| Cookie values to include when sending requests.
|
| event_hooks
|
| headers
| HTTP headers to include when sending requests.
|
| params
| Query parameters to include in the URL when sending requests.
|
| timeout

class InternalServerError(APIStatusError)
| InternalServerError(message: 'str', *, response: 'httpx.Response', body:
'object | None') -> 'None'
|
| Method resolution order:
| InternalServerError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class LengthFinishReasonError(OpenAIError)
| LengthFinishReasonError(*, completion: 'ChatCompletion') -> 'None'
|
| Method resolution order:
| LengthFinishReasonError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, completion: 'ChatCompletion') -> 'None' from
openai._exceptions.LengthFinishReasonError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'completion': 'ChatCompletion'}
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class NoneType(object)
| Methods defined here:
|
| __bool__(self, /)
| True if self else False
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __gt__(self, value, /)
| Return self>value.
|
| __hash__(self, /)
| Return hash(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __repr__(self, /)
| Return repr(self).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(*args, **kwargs)
| Create and return a new object. See help(type) for accurate signature.

class NotFoundError(APIStatusError)
| NotFoundError(message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None'
|
| Method resolution order:
| NotFoundError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[404]'}
|
| status_code = 404
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class NotGiven(builtins.object)
| A sentinel singleton class used to distinguish omitted keyword arguments
| from those passed in with the value None (which may have different
behavior).
|
| For example:
|
| ```py
| def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...
|
|
| get(timeout=1) # 1s timeout
| get(timeout=None) # No timeout
| get() # Default timeout behavior, which may not be statically known at the
method definition.
| ```
|
| Methods defined here:
|
| __bool__(self) -> 'Literal[False]' from openai._types.NotGiven
|
| __repr__(self) -> 'str' from openai._types.NotGiven
| Return repr(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __slotnames__ = []

class OpenAI(openai._base_client.SyncAPIClient)
| OpenAI(*, api_key: 'str | None' = None, organization: 'str | None' = None,
project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None, timeout:
'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' = 2,
default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.Client | None' = None,
_strict_response_validation: 'bool' = False) -> 'None'
|
| Method resolution order:
| OpenAI
| openai._base_client.SyncAPIClient
| openai._base_client.BaseClient
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, api_key: 'str | None' = None, organization: 'str | None'
= None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'Union[float, Timeout, None, NotGiven]' = NOT_GIVEN, max_retries: 'int' =
2, default_headers: 'Mapping[str, str] | None' = None, default_query: 'Mapping[str,
object] | None' = None, http_client: 'httpx.Client | None' = None,
_strict_response_validation: 'bool' = False) -> 'None' from openai._client.OpenAI
| Construct a new synchronous openai client instance.
|
| This automatically infers the following arguments from their
corresponding environment variables if they are not provided:
| - `api_key` from `OPENAI_API_KEY`
| - `organization` from `OPENAI_ORG_ID`
| - `project` from `OPENAI_PROJECT_ID`
|
| copy(self, *, api_key: 'str | None' = None, organization: 'str | None' =
None, project: 'str | None' = None, base_url: 'str | httpx.URL | None' = None,
timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN, http_client:
'httpx.Client | None' = None, max_retries: 'int | NotGiven' = NOT_GIVEN,
default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self' from openai._client.OpenAI
| Create a new client instance re-using the same options given to the
current client with optional overriding.
|
| with_options = copy(self, *, api_key: 'str | None' = None, organization:
'str | None' = None, project: 'str | None' = None, base_url: 'str | httpx.URL |
None' = None, timeout: 'float | Timeout | None | NotGiven' = NOT_GIVEN,
http_client: 'httpx.Client | None' = None, max_retries: 'int | NotGiven' =
NOT_GIVEN, default_headers: 'Mapping[str, str] | None' = None, set_default_headers:
'Mapping[str, str] | None' = None, default_query: 'Mapping[str, object] | None' =
None, set_default_query: 'Mapping[str, object] | None' = None, _extra_kwargs:
'Mapping[str, Any]' = {}) -> 'Self'
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| auth_headers
|
| default_headers
|
| qs
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'api_key': 'str', 'audio': 'resources.Audio', 'batc...
|
| __parameters__ = ()
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.SyncAPIClient:
|
| __enter__(self: '_T') -> '_T'
|
| __exit__(self, exc_type: 'type[BaseException] | None', exc: 'BaseException
| None', exc_tb: 'TracebackType | None') -> 'None'
|
| close(self) -> 'None'
| Close the underlying HTTPX client.
|
| The client will *not* be usable after this.
|
| delete(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body |
None' = None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| get(self, path: 'str', *, cast_to: 'Type[ResponseT]', options:
'RequestOptions' = {}, stream: 'bool' = False, stream_cls: 'type[_StreamT] | None'
= None) -> 'ResponseT | _StreamT'
|
| get_api_list(self, path: 'str', *, model: 'Type[object]', page:
'Type[SyncPageT]', body: 'Body | None' = None, options: 'RequestOptions' = {},
method: 'str' = 'get') -> 'SyncPageT'
|
| is_closed(self) -> 'bool'
|
| patch(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body | None'
= None, options: 'RequestOptions' = {}) -> 'ResponseT'
|
| post(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body | None'
= None, options: 'RequestOptions' = {}, files: 'RequestFiles | None' = None,
stream: 'bool' = False, stream_cls: 'type[_StreamT] | None' = None) -> 'ResponseT |
_StreamT'
|
| put(self, path: 'str', *, cast_to: 'Type[ResponseT]', body: 'Body | None' =
None, files: 'RequestFiles | None' = None, options: 'RequestOptions' = {}) ->
'ResponseT'
|
| request(self, cast_to: 'Type[ResponseT]', options: 'FinalRequestOptions',
remaining_retries: 'Optional[int]' = None, *, stream: 'bool' = False, stream_cls:
'type[_StreamT] | None' = None) -> 'ResponseT | _StreamT'
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from openai._base_client.SyncAPIClient:
|
| __orig_bases__ = (openai._base_client.BaseClient[httpx.Client, openai....
|
| ----------------------------------------------------------------------
| Methods inherited from openai._base_client.BaseClient:
|
| platform_headers(self) -> 'Dict[str, str]'
|
| ----------------------------------------------------------------------
| Readonly properties inherited from openai._base_client.BaseClient:
|
| custom_auth
|
| default_query
|
| user_agent
|
| ----------------------------------------------------------------------
| Data descriptors inherited from openai._base_client.BaseClient:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| base_url
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.

class OpenAIError(builtins.Exception)
| Method resolution order:
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.Exception:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class PermissionDeniedError(APIStatusError)
| PermissionDeniedError(message: 'str', *, response: 'httpx.Response', body:
'object | None') -> 'None'
|
| Method resolution order:
| PermissionDeniedError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[403]'}
|
| status_code = 403
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class RateLimitError(APIStatusError)
| RateLimitError(message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None'
|
| Method resolution order:
| RateLimitError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[429]'}
|
| status_code = 429
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

class RequestOptions(builtins.dict)
| Method resolution order:
| RequestOptions
| builtins.dict
| builtins.object
|
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'extra_json': ForwardRef('AnyMapping', module='open...
|
| __closed__ = False
|
| __extra_items__ = None
|
| __mutable_keys__ = frozenset({'extra_json', 'headers', 'idempotency_ke...
|
| __optional_keys__ = frozenset({'extra_json', 'headers', 'idempotency_k...
|
| __orig_bases__ = (<function TypedDict>,)
|
| __readonly_keys__ = frozenset()
|
| __required_keys__ = frozenset()
|
| __total__ = False
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __getitem__(self, key, /)
| Return self[key].
|
| __gt__(self, value, /)
| Return self>value.
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __setitem__(self, key, value, /)
| Set self[key] to value.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| get(self, key, default=None, /)
| Return the value for key if key is in the dictionary, else default.
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| pop(...)
| D.pop(k[,d]) -> v, remove specified key and return the corresponding
value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k]
= E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E:
D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...)
| See PEP 585
|
| fromkeys(iterable, value=None, /)
| Create a new dictionary with keys from iterable and values set to
value.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) class method of builtins.dict
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.dict:
|
| __hash__ = None

class Stream(typing.Generic)
| Stream(*, cast_to: 'type[_T]', response: 'httpx.Response', client:
'OpenAI') -> 'None'
|
| Provides the core interface to iterate over a synchronous stream response.
|
| Method resolution order:
| Stream
| typing.Generic
| builtins.object
|
| Methods defined here:
|
| __enter__(self) -> 'Self' from openai._streaming.Stream
|
| __exit__(self, exc_type: 'type[BaseException] | None', exc: 'BaseException
| None', exc_tb: 'TracebackType | None') -> 'None' from openai._streaming.Stream
|
| __init__(self, *, cast_to: 'type[_T]', response: 'httpx.Response', client:
'OpenAI') -> 'None' from openai._streaming.Stream
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> 'Iterator[_T]' from openai._streaming.Stream
|
| __next__(self) -> '_T' from openai._streaming.Stream
|
| __stream__(self) -> 'Iterator[_T]' from openai._streaming.Stream
|
| close(self) -> 'None' from openai._streaming.Stream
| Close the response and release the connection.
|
| Automatically called if the response body is read to completion.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'_decoder': 'SSEBytesDecoder', 'response': 'httpx.R...
|
| __orig_bases__ = (typing.Generic[~_T],)
|
| __parameters__ = (~_T,)
|
| ----------------------------------------------------------------------
| Class methods inherited from typing.Generic:
|
| __class_getitem__(...)
| Parameterizes a generic class.
|
| At least, parameterizing a generic class is the *main* thing this
| method does. For example, for some generic class `Foo`, this is called
| when we do `Foo[int]` - there, with `cls=Foo` and `params=int`.
|
| However, note that this method is also called when defining generic
| classes in the first place with `class Foo[T]: ...`.
|
| __init_subclass__(...)
| Function to initialize subclasses.
class Timeout(builtins.object)
| Timeout(timeout: 'TimeoutTypes | UnsetType' = <httpx._config.UnsetType
object at 0x726faee98290>, *, connect: 'None | float | UnsetType' =
<httpx._config.UnsetType object at 0x726faee98290>, read: 'None | float |
UnsetType' = <httpx._config.UnsetType object at 0x726faee98290>, write: 'None |
float | UnsetType' = <httpx._config.UnsetType object at 0x726faee98290>, pool:
'None | float | UnsetType' = <httpx._config.UnsetType object at 0x726faee98290>) ->
'None'
|
| Timeout configuration.
|
| **Usage**:
|
| Timeout(None) # No timeouts.
| Timeout(5.0) # 5s timeout on all operations.
| Timeout(None, connect=5.0) # 5s timeout on connect, no other timeouts.
| Timeout(5.0, connect=10.0) # 10s timeout on connect. 5s timeout elsewhere.
| Timeout(5.0, pool=None) # No timeout on acquiring connection from pool.
| # 5s timeout elsewhere.
|
| Methods defined here:
|
| __eq__(self, other: 'typing.Any') -> 'bool' from httpx._config.Timeout
| Return self==value.
|
| __init__(self, timeout: 'TimeoutTypes | UnsetType' =
<httpx._config.UnsetType object at 0x726faee98290>, *, connect: 'None | float |
UnsetType' = <httpx._config.UnsetType object at 0x726faee98290>, read: 'None |
float | UnsetType' = <httpx._config.UnsetType object at 0x726faee98290>, write:
'None | float | UnsetType' = <httpx._config.UnsetType object at 0x726faee98290>,
pool: 'None | float | UnsetType' = <httpx._config.UnsetType object at
0x726faee98290>) -> 'None' from httpx._config.Timeout
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self) -> 'str' from httpx._config.Timeout
| Return repr(self).
|
| as_dict(self) -> 'dict[str, float | None]' from httpx._config.Timeout
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __hash__ = None

Transport = class BaseTransport(builtins.object)


| Methods defined here:
|
| __enter__(self: 'T') -> 'T' from httpx._transports.base.BaseTransport
|
| __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value:
'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None'
from httpx._transports.base.BaseTransport
|
| close(self) -> 'None' from httpx._transports.base.BaseTransport
|
| handle_request(self, request: 'Request') -> 'Response' from
httpx._transports.base.BaseTransport
| Send a single HTTP request and return a response.
|
| Developers shouldn't typically ever need to call into this API
directly,
| since the Client class provides all the higher level user-facing API
| niceties.
|
| In order to properly release any network resources, the response
| stream should *either* be consumed immediately, with a call to
| `response.stream.read()`, or else the `handle_request` call should
| be followed with a try/finally block to ensuring the stream is
| always closed.
|
| Example usage:
|
| with httpx.HTTPTransport() as transport:
| req = httpx.Request(
| method=b"GET",
| url=(b"https", b"www.example.com", 443, b"/"),
| headers=[(b"Host", b"www.example.com")],
| )
| resp = transport.handle_request(req)
| body = resp.stream.read()
| print(resp.status_code, resp.headers, body)
|
|
| Takes a `Request` instance as the only argument.
|
| Returns a `Response` instance.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object

class UnprocessableEntityError(APIStatusError)
| UnprocessableEntityError(message: 'str', *, response: 'httpx.Response',
body: 'object | None') -> 'None'
|
| Method resolution order:
| UnprocessableEntityError
| APIStatusError
| APIError
| OpenAIError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {'status_code': 'Literal[422]'}
|
| status_code = 422
|
| ----------------------------------------------------------------------
| Methods inherited from APIStatusError:
|
| __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object
| None') -> 'None' from openai._exceptions.APIStatusError
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from APIError:
|
| code = None
|
| param = None
|
| ----------------------------------------------------------------------
| Data descriptors inherited from OpenAIError:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| __str__(self, /)
| Return str(self).
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args

FUNCTIONS
file_from_path(path: 'str') -> 'FileTypes'

DATA
DEFAULT_CONNECTION_LIMITS = Limits(max_connections=1000, max_keepalive...
DEFAULT_MAX_RETRIES = 2
DEFAULT_TIMEOUT = Timeout(connect=5.0, read=600.0, write=600.0, pool=6...
NOT_GIVEN = NOT_GIVEN
ProxiesTypes = typing.Union[str, httpx.Proxy, typing.Dict[Forwa...ng.U...
__all__ = ['types', '__version__', '__title__', 'NoneType', 'Transport...
__annotations__ = {'_client': 'OpenAI | None', 'api_key': 'str | None'...
__title__ = 'openai'

VERSION
1.52.2

FILE
/usr/lib/python3.12/site-packages/openai/__init__.py

You might also like