Skip to content

FIX Add an additional Microsoft target that supports api-version-sensitive Azure AI endpoints#1730

Merged
behnam-o merged 2 commits into
microsoft:mainfrom
behnam-o:dev/mai-targets
May 14, 2026
Merged

FIX Add an additional Microsoft target that supports api-version-sensitive Azure AI endpoints#1730
behnam-o merged 2 commits into
microsoft:mainfrom
behnam-o:dev/mai-targets

Conversation

@behnam-o
Copy link
Copy Markdown
Contributor

Adding an additional target to registry that sets the API version in the request URIs, because some Azure AI model deployments are sensitive to that.

Parameters such as endpoint, model, api key, for this target can be configured through environment variables, but it will always have an additional ?api-version=2024-05-01-preview query parameter. So it can constructs a target like this:

target = OpenAIChatTarget(
    endpoint="https://<project>.services.ai.azure.com/openai/deployments/<deployment>",
    api_key="<api-key>",
    model_name="<model>",
    httpx_client_kwargs={"default_query": {"api-version": "2024-05-01-preview"}},
)

in order to support an HTTP call exactly like this (with the API version param), which are not possible without the custom httpx_client_kwargs param

This is mainly to allow this target to be populated in CoPyRIT (because in the library-based notebooks, one can simply construct the target like above.)

 curl -i -X POST "https://<project>.services.ai.azure.com/openai/deployments/<deployment>/chat/completions?api-version=2024-05-01-preview" \
  -H "api-key: <api-key>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model>",
    "messages": [
      {"role": "user", "content": "Hello, what is the capital of France?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000
  }'

@behnam-o behnam-o marked this pull request as ready for review May 14, 2026 05:12
@rlundeen2
Copy link
Copy Markdown
Contributor

We maaay not need this in main; could add internally when needed

@behnam-o behnam-o added this pull request to the merge queue May 14, 2026
Merged via the queue into microsoft:main with commit 2741dce May 14, 2026
48 checks passed
@behnam-o behnam-o deleted the dev/mai-targets branch May 14, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants