MCPcopy
hub / github.com/openai/openai-python / copy

Method copy

src/openai/_client.py:1180–1266  ·  src/openai/_client.py::AsyncOpenAI.copy

Create a new client instance re-using the same options given to the current client with optional overriding.

(
        self,
        *,
        api_key: str | Callable[[], Awaitable[str]] | None = None,
        admin_api_key: str | None = None,
        workload_identity: WorkloadIdentity | None = None,
        provider: _Provider | None | NotGiven = not_given,
        organization: str | None = None,
        project: str | None = None,
        webhook_secret: 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,
        _enforce_credentials: bool | None = None,
        _extra_kwargs: Mapping[str, Any] = {},
    )

Source from the content-addressed store, hash-verified

1178 return self.api_key
1179
1180 def copy(
1181 self,
1182 *,
1183 api_key: str | Callable[[], Awaitable[str]] | None = None,
1184 admin_api_key: str | None = None,
1185 workload_identity: WorkloadIdentity | None = None,
1186 provider: _Provider | None | NotGiven = not_given,
1187 organization: str | None = None,
1188 project: str | None = None,
1189 webhook_secret: str | None = None,
1190 websocket_base_url: str | httpx.URL | None = None,
1191 base_url: str | httpx.URL | None = None,
1192 timeout: float | Timeout | None | NotGiven = not_given,
1193 http_client: httpx.AsyncClient | None = None,
1194 max_retries: int | NotGiven = not_given,
1195 default_headers: Mapping[str, str] | None = None,
1196 set_default_headers: Mapping[str, str] | None = None,
1197 default_query: Mapping[str, object] | None = None,
1198 set_default_query: Mapping[str, object] | None = None,
1199 _enforce_credentials: bool | None = None,
1200 _extra_kwargs: Mapping[str, Any] = {},
1201 ) -> Self:
1202 class="st">"""
1203 Create a new client instance re-using the same options given to the current client with optional overriding.
1204 class="st">"""
1205 if default_headers is not None and set_default_headers is not None:
1206 raise ValueError(class="st">"The `default_headers` and `set_default_headers` arguments are mutually exclusive")
1207
1208 if default_query is not None and set_default_query is not None:
1209 raise ValueError(class="st">"The `default_query` and `set_default_query` arguments are mutually exclusive")
1210
1211 provider_changed = not isinstance(provider, NotGiven) and provider is not self._provider
1212 inherited_organization = None if provider_changed else self.organization
1213 inherited_project = None if provider_changed else self.project
1214
1215 headers: Mapping[str, str] = {} if provider_changed else self._custom_headers
1216 if default_headers is not None:
1217 headers = {**headers, **default_headers}
1218 elif set_default_headers is not None:
1219 headers = set_default_headers
1220
1221 params = self._custom_query
1222 if default_query is not None:
1223 params = {**params, **default_query}
1224 elif set_default_query is not None:
1225 params = set_default_query
1226
1227 http_client = http_client or self._client
1228 next_provider = self._provider if isinstance(provider, NotGiven) else provider
1229 auth_options: dict[str, Any]
1230 if next_provider is not None:
1231 auth_options = {
1232 class="st">"provider": next_provider,
1233 class="st">"api_key": api_key,
1234 class="st">"admin_api_key": admin_api_key,
1235 class="st">"workload_identity": workload_identity,
1236 class="st">"base_url": base_url,
1237 }

Calls 2

is_givenFunction · 0.85
__class__Method · 0.80