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

Method _prepare_options

src/openai/lib/azure.py:700–719  ·  src/openai/lib/azure.py::AsyncAzureOpenAI._prepare_options
(self, options: FinalRequestOptions)

Source from the content-addressed store, hash-verified

698
699 @override
700 async def _prepare_options(self, options: FinalRequestOptions) -> FinalRequestOptions:
701 headers: dict[str, str | Omit] = {**options.headers} if is_given(options.headers) else {}
702
703 options = model_copy(options)
704 options.headers = headers
705
706 azure_ad_token = await self._get_azure_ad_token()
707 if azure_ad_token is not None:
708 if not _has_header(headers, class="st">"Authorization"):
709 headers[class="st">"Authorization"] = fclass="st">"Bearer {azure_ad_token}"
710 elif self.api_key and self.api_key != API_KEY_SENTINEL:
711 if not _has_header(headers, class="st">"api-key"):
712 headers[class="st">"api-key"] = self.api_key
713 elif _has_auth_header(headers) or _has_auth_header(self.default_headers):
714 pass
715 else:
716 class="cm"># should never be hit
717 raise ValueError(class="st">"Unable to handle auth")
718
719 return options
720
721 async def _configure_realtime(self, model: str, extra_query: Query) -> tuple[httpx.URL, dict[str, str]]:
722 auth_headers = {}

Callers

nothing calls this directly

Calls 5

_get_azure_ad_tokenMethod · 0.95
is_givenFunction · 0.85
model_copyFunction · 0.85
_has_auth_headerFunction · 0.85
_has_headerFunction · 0.70

Tested by

no test coverage detected