| 699 | |
| 700 | |
| 701 | class AsyncOpenAI(AsyncAPIClient): |
| 702 | # client options |
| 703 | api_key: str |
| 704 | admin_api_key: str | None |
| 705 | workload_identity: WorkloadIdentity | None |
| 706 | organization: str | None |
| 707 | project: str | None |
| 708 | webhook_secret: str | None |
| 709 | _workload_identity_auth: WorkloadIdentityAuth | None |
| 710 | _provider: _Provider | None |
| 711 | _provider_runtime: _ProviderRuntime | None |
| 712 | |
| 713 | websocket_base_url: str | httpx.URL | None |
| 714 | """Base URL for WebSocket connections. |
| 715 | |
| 716 | If not specified, the default base URL will be used, with 'wss://' replacing the |
| 717 | 'http://' or 'https://' scheme. For example: 'http://example.com' becomes |
| 718 | 'wss://example.com' |
| 719 | """ |
| 720 | |
| 721 | def __init__( |
| 722 | self, |
| 723 | *, |
| 724 | api_key: str | Callable[[], Awaitable[str]] | None = None, |
| 725 | admin_api_key: str | None = None, |
| 726 | workload_identity: WorkloadIdentity | None = None, |
| 727 | organization: str | None = None, |
| 728 | project: str | None = None, |
| 729 | webhook_secret: str | None = None, |
| 730 | provider: _Provider | None = None, |
| 731 | base_url: str | httpx.URL | None = None, |
| 732 | websocket_base_url: str | httpx.URL | None = None, |
| 733 | timeout: float | Timeout | None | NotGiven = not_given, |
| 734 | max_retries: int = DEFAULT_MAX_RETRIES, |
| 735 | default_headers: Mapping[str, str] | None = None, |
| 736 | default_query: Mapping[str, object] | None = None, |
| 737 | # Configure a custom httpx client. |
| 738 | # We provide a `DefaultAsyncHttpxClient` class that you can pass to retain the default values we use for `limits`, `timeout` & `follow_redirects`. |
| 739 | # See the [httpx documentation](https://www.python-httpx.org/api/#asyncclient) for more details. |
| 740 | http_client: httpx.AsyncClient | None = None, |
| 741 | # Enable or disable schema validation for data returned by the API. |
| 742 | # When enabled an error APIResponseValidationError is raised |
| 743 | # if the API responds with invalid data for the expected schema. |
| 744 | # |
| 745 | # This parameter may be removed or changed in the future. |
| 746 | # If you rely on this feature, please open a GitHub issue |
| 747 | # outlining your use-case to help us decide if it should be |
| 748 | # part of our public interface in the future. |
| 749 | _strict_response_validation: bool = False, |
| 750 | _enforce_credentials: bool = True, |
| 751 | ) -> None: |
| 752 | """Construct a new async AsyncOpenAI client instance. |
| 753 | |
| 754 | This automatically infers the following arguments from their corresponding environment variables if they are not provided: |
| 755 | - `api_key` from `OPENAI_API_KEY` |
| 756 | - `admin_api_key` from `OPENAI_ADMIN_KEY` |
| 757 | - `organization` from `OPENAI_ORG_ID` |
| 758 | - `project` from `OPENAI_PROJECT_ID` |
no outgoing calls