Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Private/Invoke-OAIBeta.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ function Invoke-OAIBeta {

'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.
$headers['OpenAI-Organization'] = "$($AzOAISecrets.organizationId)"
}
else {
$headers.Remove('OpenAI-Organization')
}

if ($Body -isnot [System.IO.Stream]) {
if ($null -ne $Body -and $Body.Contains("model") ) {
Expand Down
16 changes: 12 additions & 4 deletions Public/Set-AzOAISecrets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ The URI of the Azure OAI.
The API key for accessing the Azure OAI.

.PARAMETER apiVersion
The version of the Azure OAI.
The version of the Azure OAI in YYYY-MM-DD format.

.PARAMETER deploymentName
The name of the deployment.
The name of the AI model deployment.

.PARAMETER organizationId
The organization ID associated with the Azure OAI. This parameter is optional.

.EXAMPLE
Set-AzOAISecrets -apiURI "https://api.example.com" -apiKEY "myApiKey" -apiVersion "v1" -deploymentName "MyDeployment"
Set-AzOAISecrets -apiURI "https://api.example.com" -apiKEY "myApiKey" -apiVersion "2024-10-21" -deploymentName "MyDeployment"
Sets the Azure OAI secrets with the specified values.

.NOTES
See https://learn.microsoft.com/en-us/azure/ai-foundry/openai/reference for more information on Azure OpenAI API version
#>

function Set-AzOAISecrets {
Expand All @@ -33,11 +38,14 @@ function Set-AzOAISecrets {
[Parameter(Mandatory)]
$apiVersion,
[Parameter(Mandatory)]
$deploymentName
$deploymentName,
[Parameter(Mandatory=$false)]
$organizationId = $null
)

$script:AzOAISecrets['apiURI'] = $apiURI
$script:AzOAISecrets['apiKEY'] = $apiKEY
$script:AzOAISecrets['apiVersion'] = $apiVersion
$script:AzOAISecrets['deploymentName'] = $deploymentName
$script:AzOAISecrets['organizationId'] = $organizationId
}
Loading