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 Omit 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' | | Common base class for all non-exit exceptions. | | 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' | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes inherited from APIError: | | __annotations__ = {'body': 'object | None', 'code': 'Optional[str]', '... | | code = None | | param = None | | ---------------------------------------------------------------------- | Data descriptors inherited from OpenAIError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Common base class for all non-exit exceptions. | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Common base class for all non-exit exceptions. | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Common base class for all non-exit exceptions. | | Method resolution order: | APITimeoutError | APIConnectionError | APIError | OpenAIError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, request: 'httpx.Request') -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes inherited from APIError: | | __annotations__ = {'body': 'object | None', 'code': 'Optional[str]', '... | | code = None | | param = None | | ---------------------------------------------------------------------- | Data descriptors inherited from OpenAIError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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(*args, **kwds) | | Abstract base class for generic types. | | A generic type is typically declared by inheriting from | this class parameterized with one or more type variables. | For example, a generic mapping type might be defined as:: | | class Mapping(Generic[KT, VT]): | def __getitem__(self, key: KT) -> VT: | ... | # Etc. | | This class can then be used as follows:: | | def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: | try: | return mapping[key] | except KeyError: | return default | | 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, websocket_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' | Construct a new async AsyncOpenAI 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, websocket_base_url: 'str | httpx.URL | 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' | 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, websocket_base_url: 'str | httpx.URL | 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': 'audio.AsyncAudio', 'bat... | | __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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | base_url | | ---------------------------------------------------------------------- | Class methods inherited from typing.Generic: | | __class_getitem__(params) from builtins.type | | __init_subclass__(*args, **kwargs) from builtins.type | This method is called when a class is subclassed. | | The default implementation does nothing. It may be | overridden to extend subclasses. | | ---------------------------------------------------------------------- | Static methods inherited from typing.Generic: | | __new__(cls, *args, **kwds) | Create and return a new object. See help(type) for accurate signature. class AsyncOpenAI(openai._base_client.AsyncAPIClient) | AsyncOpenAI(*args, **kwds) | | Abstract base class for generic types. | | A generic type is typically declared by inheriting from | this class parameterized with one or more type variables. | For example, a generic mapping type might be defined as:: | | class Mapping(Generic[KT, VT]): | def __getitem__(self, key: KT) -> VT: | ... | # Etc. | | This class can then be used as follows:: | | def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: | try: | return mapping[key] | except KeyError: | return default | | 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, websocket_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' | Construct a new async AsyncOpenAI 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, websocket_base_url: 'str | httpx.URL | 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' | 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, websocket_base_url: 'str | httpx.URL | 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': 'audio.AsyncAudio', 'bat... | | __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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | base_url | | ---------------------------------------------------------------------- | Class methods inherited from typing.Generic: | | __class_getitem__(params) from builtins.type | | __init_subclass__(*args, **kwargs) from builtins.type | This method is called when a class is subclassed. | | The default implementation does nothing. It may be | overridden to extend subclasses. | | ---------------------------------------------------------------------- | Static methods inherited from typing.Generic: | | __new__(cls, *args, **kwds) | Create and return a new object. See help(type) for accurate signature. class AsyncStream(typing.Generic) | AsyncStream(*args, **kwds) | | 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' | | async __aexit__(self, exc_type: 'type[BaseException] | None', exc: 'BaseException | None', exc_tb: 'TracebackType | None') -> 'None' | | async __aiter__(self) -> 'AsyncIterator[_T]' | | async __anext__(self) -> '_T' | | __init__(self, *, cast_to: 'type[_T]', response: 'httpx.Response', client: 'AsyncOpenAI') -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | async __stream__(self) -> 'AsyncIterator[_T]' | | async close(self) -> 'None' | 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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | 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__(params) from builtins.type | | __init_subclass__(*args, **kwargs) from builtins.type | This method is called when a class is subclassed. | | The default implementation does nothing. It may be | overridden to extend subclasses. | | ---------------------------------------------------------------------- | Static methods inherited from typing.Generic: | | __new__(cls, *args, **kwds) | Create and return a new object. See help(type) for accurate signature. class AuthenticationError(APIStatusError) | AuthenticationError(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: | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Raised when an API response has a status code of 4xx or 5xx. | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Usage docs: https://docs.pydantic.dev/2.10/concepts/models/ | | A base class for creating Pydantic models. | | Attributes: | __class_vars__: The names of the class variables defined on the model. | __private_attributes__: Metadata about the private attributes of the model. | __signature__: The synthesized `__init__` [`Signature`][inspect.Signature] of the model. | | __pydantic_complete__: Whether model building is completed, or if there are still undefined fields. | __pydantic_core_schema__: The core schema of the model. | __pydantic_custom_init__: Whether the model has a custom `__init__` function. | __pydantic_decorators__: Metadata containing the decorators defined on the model. | This replaces `Model.__validators__` and `Model.__root_validators__` from Pydantic V1. | __pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to | __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these. | __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models. | __pydantic_post_init__: The name of the post-init method for the model, if defined. | __pydantic_root_model__: Whether the model is a [`RootModel`][pydantic.root_model.RootModel]. | __pydantic_serializer__: The `pydantic-core` `SchemaSerializer` used to dump instances of the model. | __pydantic_validator__: The `pydantic-core` `SchemaValidator` used to validate instances of the model. | | __pydantic_fields__: A dictionary of field names and their corresponding [`FieldInfo`][pydantic.fields.FieldInfo] objects. | __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. | | __pydantic_extra__: A dictionary containing extra values, if [`extra`][pydantic.config.ConfigDict.extra] | is set to `'allow'`. | __pydantic_fields_set__: The names of fields explicitly set during instantiation. | __pydantic_private__: Values of private attributes set on the model instance. | | Method resolution order: | BaseModel | pydantic.main.BaseModel | builtins.object | | Methods defined here: | | __str__(self) -> 'str' | 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]' | 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' | 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 pydantic._internal._model_construction.ModelMetaclass | # 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 pydantic._internal._model_construction.ModelMetaclass | # 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 (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __abstractmethods__ = frozenset() | | __annotations__ = {'model_config': 'ClassVar[ConfigDict]'} | | __class_vars__ = set() | | __private_attributes__ = {} | | __pydantic_complete__ = True | | __pydantic_computed_fields__ = {} | | __pydantic_core_schema__ = {'cls': , 'config... | | __pydantic_custom_init__ = False | | __pydantic_decorators__ = DecoratorInfos(validators={}, field_validato... | | __pydantic_fields__ = {} | | __pydantic_generic_metadata__ = {'args': (), 'origin': None, 'paramete... | | __pydantic_parent_namespace__ = None | | __pydantic_post_init__ = None | | __pydantic_serializer__ = SchemaSerializer(serializer=Model( | Model... | | __pydantic_validator__ = SchemaValidator(title="BaseModel", validator=... | | model_config = {'defer_build': True, 'extra': 'allow'} | | ---------------------------------------------------------------------- | 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]' | | __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]' | Used by devtools (https://python-devtools.helpmanual.io/) to pretty print objects. | | __replace__(self, **changes: 'Any') -> 'Self' | # Because we make use of `@dataclass_transform()`, `__replace__` is already synthesized by | # type checkers, so we define the implementation in this `if not TYPE_CHECKING:` block: | | __repr__(self) -> 'str' | Return repr(self). | | __repr_args__(self) -> '_repr.ReprArgs' | | __repr_name__(self) -> 'str' | Name of the instance's class, used in __repr__. | | __repr_recursion__(self, object: 'Any') -> 'str' | Returns the string representation of a recursive object. | | __repr_str__(self, join_str: 'str') -> 'str' | | __rich_repr__(self) -> 'RichReprResult' | 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: | | ```python {test="skip" lint="skip"} | 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: 'Mapping[str, Any] | None' = None, deep: 'bool' = False) -> 'Self' | Usage docs: https://docs.pydantic.dev/2.10/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.10/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.10/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' from pydantic._internal._model_construction.ModelMetaclass | | __get_pydantic_core_schema__(source: 'type[BaseModel]', handler: 'GetCoreSchemaHandler', /) -> 'CoreSchema' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | | model_json_schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', schema_generator: 'type[GenerateJsonSchema]' = , mode: 'JsonSchemaMode' = 'validation') -> 'dict[str, Any]' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | 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: 'MappingNamespace | None' = None) -> 'bool | None' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | Usage docs: https://docs.pydantic.dev/2.10/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' from pydantic._internal._model_construction.ModelMetaclass | 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' from pydantic._internal._model_construction.ModelMetaclass | | parse_obj(obj: 'Any') -> 'Self' from pydantic._internal._model_construction.ModelMetaclass | | parse_raw(b: 'str | bytes', *, content_type: 'str | None' = None, encoding: 'str' = 'utf8', proto: 'DeprecatedParseProtocol | None' = None, allow_pickle: 'bool' = False) -> 'Self' from pydantic._internal._model_construction.ModelMetaclass | | schema(by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}') -> 'Dict[str, Any]' from pydantic._internal._model_construction.ModelMetaclass | | schema_json(*, by_alias: 'bool' = True, ref_template: 'str' = '#/$defs/{model}', **dumps_kwargs: 'Any') -> 'str' from pydantic._internal._model_construction.ModelMetaclass | | update_forward_refs(**localns: 'Any') -> 'None' from pydantic._internal._model_construction.ModelMetaclass | | validate(value: 'Any') -> 'Self' from pydantic._internal._model_construction.ModelMetaclass | | ---------------------------------------------------------------------- | Readonly properties inherited from pydantic.main.BaseModel: | | __fields_set__ | | model_computed_fields | Get metadata about the computed fields defined on the model. | | Deprecation warning: you should be getting this information from the model class, not from an instance. | In V3, this property will be removed from the `BaseModel` class. | | Returns: | A mapping of computed field names to [`ComputedFieldInfo`][pydantic.fields.ComputedFieldInfo] objects. | | 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 | Get metadata about the fields defined on the model. | | Deprecation warning: you should be getting this information from the model class, not from an instance. | In V3, this property will be removed from the `BaseModel` class. | | Returns: | A mapping of field names to [`FieldInfo`][pydantic.fields.FieldInfo] objects. | | 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 (if defined) | | __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(*args, **kwds) | | Abstract base class for generic types. | | A generic type is typically declared by inheriting from | this class parameterized with one or more type variables. | For example, a generic mapping type might be defined as:: | | class Mapping(Generic[KT, VT]): | def __getitem__(self, key: KT) -> VT: | ... | # Etc. | | This class can then be used as follows:: | | def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: | try: | return mapping[key] | except KeyError: | return default | | 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, websocket_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' | 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, websocket_base_url: 'str | httpx.URL | 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' | 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, websocket_base_url: 'str | httpx.URL | 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': 'audio.Audio', 'batches'... | | __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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | base_url | | ---------------------------------------------------------------------- | Class methods inherited from typing.Generic: | | __class_getitem__(params) from builtins.type | | __init_subclass__(*args, **kwargs) from builtins.type | This method is called when a class is subclassed. | | The default implementation does nothing. It may be | overridden to extend subclasses. | | ---------------------------------------------------------------------- | Static methods inherited from typing.Generic: | | __new__(cls, *args, **kwds) | Create and return a new object. See help(type) for accurate signature. class ConflictError(APIStatusError) | ConflictError(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: | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Common base class for all non-exit exceptions. | | Method resolution order: | ContentFilterFinishReasonError | OpenAIError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self) -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors inherited from OpenAIError: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | An asynchronous HTTP client, with connection pooling, HTTP/2, redirects, | cookie persistence, etc. | | It can be shared between tasks. | | Usage: | | ```python | >>> async with httpx.AsyncClient() as client: | >>> response = await client.get('https://example.org') | ``` | | **Parameters:** | | * **auth** - *(optional)* An authentication class to use when sending | requests. | * **params** - *(optional)* Query parameters to include in request URLs, as | a string, dictionary, or sequence of two-tuples. | * **headers** - *(optional)* Dictionary of HTTP headers to include when | sending requests. | * **cookies** - *(optional)* Dictionary of Cookie items to include when | sending requests. | * **verify** - *(optional)* Either `True` to use an SSL context with the | default CA bundle, `False` to disable verification, or an instance of | `ssl.SSLContext` to use a custom context. | * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be | enabled. Defaults to `False`. | * **proxy** - *(optional)* A proxy URL where all the traffic should be routed. | * **timeout** - *(optional)* The timeout configuration to use when sending | requests. | * **limits** - *(optional)* The limits configuration to use. | * **max_redirects** - *(optional)* The maximum number of redirect responses | that should be followed. | * **base_url** - *(optional)* A URL to use as the base when building | request URLs. | * **transport** - *(optional)* A transport class to use for sending requests | over the network. | * **trust_env** - *(optional)* Enables or disables usage of environment | variables for configuration. | * **default_encoding** - *(optional)* The default encoding to use for decoding | response text, if no charset information is included in a response Content-Type | header. Set to a callable for automatic character set detection. Default: "utf-8". | | Method resolution order: | _DefaultAsyncHttpxClient | httpx.AsyncClient | httpx._client.BaseClient | builtins.object | | Methods defined here: | | __init__(self, **kwargs: 'Any') -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from httpx.AsyncClient: | | async __aenter__(self: 'U') -> 'U' | | async __aexit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' | | async aclose(self) -> 'None' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = ) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'typing.AsyncIterator[Response]' | 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' = , 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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | 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' | | An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc. | | It can be shared between threads. | | Usage: | | ```python | >>> client = httpx.Client() | >>> response = client.get('https://example.org') | ``` | | **Parameters:** | | * **auth** - *(optional)* An authentication class to use when sending | requests. | * **params** - *(optional)* Query parameters to include in request URLs, as | a string, dictionary, or sequence of two-tuples. | * **headers** - *(optional)* Dictionary of HTTP headers to include when | sending requests. | * **cookies** - *(optional)* Dictionary of Cookie items to include when | sending requests. | * **verify** - *(optional)* Either `True` to use an SSL context with the | default CA bundle, `False` to disable verification, or an instance of | `ssl.SSLContext` to use a custom context. | * **http2** - *(optional)* A boolean indicating if HTTP/2 support should be | enabled. Defaults to `False`. | * **proxy** - *(optional)* A proxy URL where all the traffic should be routed. | * **timeout** - *(optional)* The timeout configuration to use when sending | requests. | * **limits** - *(optional)* The limits configuration to use. | * **max_redirects** - *(optional)* The maximum number of redirect responses | that should be followed. | * **base_url** - *(optional)* A URL to use as the base when building | request URLs. | * **transport** - *(optional)* A transport class to use for sending requests | over the network. | * **trust_env** - *(optional)* Enables or disables usage of environment | variables for configuration. | * **default_encoding** - *(optional)* The default encoding to use for decoding | response text, if no charset information is included in a response Content-Type | header. Set to a callable for automatic character set detection. Default: "utf-8". | | Method resolution order: | _DefaultHttpxClient | httpx.Client | httpx._client.BaseClient | builtins.object | | Methods defined here: | | __init__(self, **kwargs: 'Any') -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from httpx.Client: | | __enter__(self: 'T') -> 'T' | | __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' | | close(self) -> 'None' | Close transport and proxies. | | delete(self, url: 'URL | str', *, params: 'QueryParamTypes | None' = None, headers: 'HeaderTypes | None' = None, cookies: 'CookieTypes | None' = None, auth: 'AuthTypes | UseClientDefault' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = ) -> 'Response' | 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' = , follow_redirects: 'bool | UseClientDefault' = , timeout: 'TimeoutTypes | UseClientDefault' = , extensions: 'RequestExtensions | None' = None) -> 'typing.Iterator[Response]' | 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' = , 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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | 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' | | Raised when an API response has a status code of 4xx or 5xx. | | Method resolution order: | InternalServerError | APIStatusError | APIError | OpenAIError | builtins.Exception | builtins.BaseException | builtins.object | | Methods inherited from APIStatusError: | | __init__(self, message: 'str', *, response: 'httpx.Response', body: 'object | None') -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data and other attributes inherited from APIStatusError: | | __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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Common base class for all non-exit exceptions. | | Method resolution order: | LengthFinishReasonError | OpenAIError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, *, completion: 'ChatCompletion') -> 'None' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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, /) | self != 0 | | __repr__(self, /) | Return repr(self). | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(*args, **kwargs) from builtins.type | 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' | | Raised when an API response has a status code of 4xx or 5xx. | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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]' | | __repr__(self) -> 'str' | Return repr(self). | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class Omit(builtins.object) | In certain situations you need to be able to represent a case where a default value has | to be explicitly removed and `None` is not an appropriate substitute, for example: | | ```py | # as the default `Content-Type` header is `application/json` that will be sent | client.post("/upload/files", files={"file": b"my raw file content"}) | | # you can't explicitly override the header as it has to be dynamically generated | # to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983' | client.post(..., headers={"Content-Type": "multipart/form-data"}) | | # instead you can remove the default `application/json` header by passing Omit | client.post(..., headers={"Content-Type": Omit()}) | ``` | | Methods defined here: | | __bool__(self) -> 'Literal[False]' | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class OpenAI(openai._base_client.SyncAPIClient) | OpenAI(*args, **kwds) | | Abstract base class for generic types. | | A generic type is typically declared by inheriting from | this class parameterized with one or more type variables. | For example, a generic mapping type might be defined as:: | | class Mapping(Generic[KT, VT]): | def __getitem__(self, key: KT) -> VT: | ... | # Etc. | | This class can then be used as follows:: | | def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: | try: | return mapping[key] | except KeyError: | return default | | 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, websocket_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' | 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, websocket_base_url: 'str | httpx.URL | 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' | 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, websocket_base_url: 'str | httpx.URL | 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': 'audio.Audio', 'batches'... | | __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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | base_url | | ---------------------------------------------------------------------- | Class methods inherited from typing.Generic: | | __class_getitem__(params) from builtins.type | | __init_subclass__(*args, **kwargs) from builtins.type | This method is called when a class is subclassed. | | The default implementation does nothing. It may be | overridden to extend subclasses. | | ---------------------------------------------------------------------- | Static methods inherited from typing.Generic: | | __new__(cls, *args, **kwds) | Create and return a new object. See help(type) for accurate signature. class OpenAIError(builtins.Exception) | Common base class for all non-exit exceptions. | | Method resolution order: | OpenAIError | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | 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) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Raised when an API response has a status code of 4xx or 5xx. | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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' | | Raised when an API response has a status code of 4xx or 5xx. | | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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) | dict() -> new empty dictionary | dict(mapping) -> new dictionary initialized from a mapping object's | (key, value) pairs | dict(iterable) -> new dictionary initialized as if via: | d = {} | for k, v in iterable: | d[k] = v | dict(**kwargs) -> new dictionary initialized with the name=value pairs | in the keyword argument list. For example: dict(one=1, two=2) | | Method resolution order: | RequestOptions | builtins.dict | builtins.object | | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __annotations__ = {'extra_json': ForwardRef('AnyMapping'), 'headers': ... | | __closed__ = False | | __extra_items__ = None | | __mutable_keys__ = frozenset({'extra_json', 'headers', 'idempotency_ke... | | __optional_keys__ = frozenset({'extra_json', 'headers', 'idempotency_k... | | __orig_bases__ = (,) | | __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__(...) | x.__getitem__(y) <==> x[y] | | __gt__(self, value, /) | Return self>value. | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self 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 key is not found, d is returned if given, otherwise KeyError is raised | | 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: | | fromkeys(iterable, value=None, /) from typing_extensions._TypedDictMeta | Create a new dictionary with keys from iterable and values set to value. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.dict: | | __new__(*args, **kwargs) from builtins.type | 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(*args, **kwds) | | 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' | | __exit__(self, exc_type: 'type[BaseException] | None', exc: 'BaseException | None', exc_tb: 'TracebackType | None') -> 'None' | | __init__(self, *, cast_to: 'type[_T]', response: 'httpx.Response', client: 'OpenAI') -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | __iter__(self) -> 'Iterator[_T]' | | __next__(self) -> '_T' | | __stream__(self) -> 'Iterator[_T]' | | close(self) -> 'None' | 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 (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | 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__(params) from builtins.type | | __init_subclass__(*args, **kwargs) from builtins.type | This method is called when a class is subclassed. | | The default implementation does nothing. It may be | overridden to extend subclasses. | | ---------------------------------------------------------------------- | Static methods inherited from typing.Generic: | | __new__(cls, *args, **kwds) | Create and return a new object. See help(type) for accurate signature. class Timeout(builtins.object) | Timeout(timeout: 'TimeoutTypes | UnsetType' = , *, connect: 'None | float | UnsetType' = , read: 'None | float | UnsetType' = , write: 'None | float | UnsetType' = , pool: 'None | float | UnsetType' = ) -> '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' | Return self==value. | | __init__(self, timeout: 'TimeoutTypes | UnsetType' = , *, connect: 'None | float | UnsetType' = , read: 'None | float | UnsetType' = , write: 'None | float | UnsetType' = , pool: 'None | float | UnsetType' = ) -> 'None' | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) -> 'str' | Return repr(self). | | as_dict(self) -> 'dict[str, float | None]' | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None Transport = class BaseTransport(builtins.object) | Methods defined here: | | __enter__(self: 'T') -> 'T' | | __exit__(self, exc_type: 'type[BaseException] | None' = None, exc_value: 'BaseException | None' = None, traceback: 'TracebackType | None' = None) -> 'None' | | close(self) -> 'None' | | handle_request(self, request: 'Request') -> 'Response' | 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 (if defined) | | __weakref__ | list of weak references to the object (if defined) class UnprocessableEntityError(APIStatusError) | UnprocessableEntityError(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: | 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' | 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 (if defined) | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | 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, write=600, pool=600) 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.65.2 FILE /home/boomer/.local/lib/python3.8/site-packages/openai/__init__.py [('_has_azure_ad_credentials', ), ('_has_azure_credentials', ), ('_has_openai_credentials', ), ('_load_client', ), ('_reset_client', ), ('_setup_logging', ), ('file_from_path', ), ('override', ), ('pydantic_function_tool', )] test