You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""Gets a valid AAD token to authenticate the request.
57
+
58
+
.. note::
59
+
60
+
Do not directly interact with this API, it will be called
61
+
automatically when a token is needed for the request.
62
+
"""
38
63
if (
39
64
self._cached_tokenisNone
40
65
or (self._cached_token.expires_on-time.time()) <300
@@ -49,15 +74,25 @@ def get_token(self) -> str:
49
74
classApiKeyAuth:
50
75
"""Authentication using an API key"""
51
76
52
-
def__repr__(self):
53
-
returnf"ApiKeyAuth(api_key=<redacted>)"
54
-
55
-
def__init__(self, key: str=""):
56
-
"""Create a new ApiKeyAuth instance. If no key is passed, it will use ~openai.api_key"""
77
+
def__repr__(self) ->str:
78
+
return"ApiKeyAuth(api_key=<redacted>)"
79
+
80
+
def__init__(self, key: str="") ->None:
81
+
"""Create a new ApiKeyAuth instance.
82
+
83
+
:param str key: The API key associated with your account.
84
+
If no key is passed, it will use ~openai.api_key
85
+
"""
57
86
self.key=keyoropenai.api_key
58
87
59
88
defget_token(self) ->str:
60
-
"""Get the API key"""
89
+
"""Get the API key
90
+
91
+
.. note::
92
+
93
+
Do not directly interact with this API, it will be called
94
+
automatically when a token is needed for the request.
95
+
"""
61
96
returnself.key
62
97
63
98
@@ -75,12 +110,16 @@ def __init__(
75
110
organization: str="",
76
111
):
77
112
"""Create a new OpenAI client.
78
-
113
+
79
114
:keyword str api_base: The base URL for the API. If not specified, based on ~opeanai.api_base
80
-
:keyword auth: The authentication method or key to use. If the string value "azuredefault" is passed, it will use ~azure.identity.DefaultAzureCredential
115
+
:keyword auth: The authentication method or key to use. If the string value "azuredefault" is passed,
116
+
it will use ~azure.identity.DefaultAzureCredential
81
117
:paramtype auth: str or ~openai.client.ApiKeyAuth or ~openai.client.AzureTokenAuth
82
-
:keyword str api_version: The API version to use. If not specified, based on ~openai.api_version or ~openai.client.LATEST_AZURE_API_VERSION.
118
+
:keyword str api_version: The API version to use. If not specified, based on ~openai.api_version
119
+
or ~openai.client.LATEST_AZURE_API_VERSION.
83
120
:keyword str backend: One of 'azure' or 'openai'. If not specified, inferred from the auth method or ~openai.api_type
121
+
:keyword str organization: The identifier of the organization to use for API requests.
raiseValueError("You are using the 'openai.com' endpoint with an Azure credential or API type. Please provide the endpoint to your Azure resource instead.")
0 commit comments