Skip to content

Added optional OpenAI-Organization header to AzOAI#99

Merged
dfinke merged 6 commits intodfinke:mainfrom
jmkloz:main
Jul 11, 2025
Merged

Added optional OpenAI-Organization header to AzOAI#99
dfinke merged 6 commits intodfinke:mainfrom
jmkloz:main

Conversation

@jmkloz
Copy link
Contributor

@jmkloz jmkloz commented Jul 11, 2025

Some organizations that use the Azure OpenAI implementation require the OpenAI-Organization header to be set. This change allows for this optional field to be set.

@dfinke dfinke requested a review from Copilot July 11, 2025 17:51
@dfinke dfinke self-assigned this Jul 11, 2025
@dfinke dfinke added enhancement New feature or request investigate needs review for won't fix or plan to fix labels Jul 11, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for an optional OpenAI-Organization header in the Azure OpenAI cmdlets.

  • Introduces an optional organizationId parameter in Set-AzOAISecrets
  • Stores the organizationId in the global secrets and updates Invoke-OAIBeta to set/remove the OpenAI-Organization header
  • Enhances help comments with version formatting and a new .NOTES section

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Public/Set-AzOAISecrets.ps1 Added optional organizationId parameter, updated help block for apiVersion and deploymentName, and assigned the new field to $script:AzOAISecrets
Private/Invoke-OAIBeta.ps1 Added conditional logic to include or remove the OpenAI-Organization header based on organizationId
Comments suppressed due to low confidence (2)

Public/Set-AzOAISecrets.ps1:24

  • Consider adding an example that demonstrates using the new -organizationId parameter in the .EXAMPLE section to help users understand how to set this optional header.
Set-AzOAISecrets -apiURI "https://api.example.com" -apiKEY "myApiKey" -apiVersion "2024-10-21" -deploymentName "MyDeployment"

Private/Invoke-OAIBeta.ps1:61

  • There are no tests covering the new OpenAI-Organization header logic. Consider adding unit tests for when organizationId is provided and when it is omitted to ensure correct header behavior.
            if($AzOAISecrets.organizationId) {


'AzureOpenAI' {
$headers['api-key'] = "$($AzOAISecrets.apiKEY)"
if($AzOAISecrets.organizationId) {
Copy link

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition if ($AzOAISecrets.organizationId) will treat an empty string as true. Consider using if (-not [string]::IsNullOrEmpty($AzOAISecrets.organizationId)) to avoid sending an empty header value.

Suggested change
if($AzOAISecrets.organizationId) {
if (-not [string]::IsNullOrEmpty($AzOAISecrets.organizationId)) {

Copilot uses AI. Check for mistakes.
@dfinke
Copy link
Owner

dfinke commented Jul 11, 2025

@jmkloz Thank you for the PR! Are you on social media I can give a shout out to?

@dfinke dfinke merged commit d75b208 into dfinke:main Jul 11, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request investigate needs review for won't fix or plan to fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants