Skip to content

[Inference API] Adding custom headers for Azure OpenAI#6134

Merged
jonathan-buttner merged 7 commits intomainfrom
ia-azure-openai-headers
Mar 23, 2026
Merged

[Inference API] Adding custom headers for Azure OpenAI#6134
jonathan-buttner merged 7 commits intomainfrom
ia-azure-openai-headers

Conversation

@jonathan-buttner
Copy link
Copy Markdown
Contributor

This PR adds the docs for the custom headers field within task_settings for Azure OpenAI. The Elasticsearch functionality was added in this PR: elastic/elasticsearch#142969

description:
Run `POST _inference/chat_completion/reasoning-chat-completion/_stream` to perform a chat completion task,
using both `effort` parameter based reasoning configuration and including reasoning generated by the model on previous step.
Run `POST _inference/chat_completion/reasoning-chat-completion/_stream` to perform a chat completion task, using both
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this was an automated change 🤔

description:
Run `POST _inference/chat_completion/reasoning-chat-completion/_stream` to perform a chat completion task,
using both `enabled` parameter based reasoning configuration and including reasoning generated by the model on previous step.
Run `POST _inference/chat_completion/reasoning-chat-completion/_stream` to perform a chat completion task, using both
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this was an automated change 🤔

export class OpenAITaskSettings {
/**
* For a `completion`, `chat_completion`, or `text_embedding` task, specify the user issuing the request.
* Specifies the user issuing the request.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Figured I'd clean this one up, the user works for all task types so no reason to specify which ones.

@github-actions
Copy link
Copy Markdown
Contributor

Following you can find the validation changes against the target branch for the APIs.

No changes detected.

You can validate these APIs yourself by using the make validate target.

Copy link
Copy Markdown
Contributor

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic left a comment

Choose a reason for hiding this comment

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

Looks good to me. I left a minor suggestion.

* Specifies custom HTTP header parameters.
* For example:
* ```
* "headers":{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* "headers":{
* "headers": {

* }
* ```
*/
headers?: UserDefinedValue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

UserDefinedValue is usually the last resort when data has no regular structure. Could this be a Map<String,String> ?

Copy link
Copy Markdown
Contributor Author

@jonathan-buttner jonathan-buttner Mar 23, 2026

Choose a reason for hiding this comment

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

Yeah good point, I'll switch to use Record<String, String>.

@jonathan-buttner jonathan-buttner added the skip-backport This pull request should not be backported label Mar 23, 2026
* ```
*/
headers?: UserDefinedValue
headers?: Dictionary<string, string>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@l-trotta should I backport this change? This is the other place we were already using UserDefinedValue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there's even a couple more places in the same file? I'd change them all and not backport, so that the changes only affect 9.4

* The parameters the functional accepts. This should be formatted as a JSON object.
*/
parameters?: UserDefinedValue
parameters?: Dictionary<string, UserDefinedValue>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@l-trotta parameters is expected to be a json object. I'm happy to change this to something else if you have a better idea.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hmm I see there are multiple of this as well, and since there's no hint of the structure I'd keep this as a UserDefinedValue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll switch it back.

search
}

export type CustomServiceQueryParameter = string[]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@l-trotta ideally this would be [string, string] but I got an error that a tuple isn't supported.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this a case where the server will return error if there's more or less than 2 items?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah the server will validate that it's an array of strings of length 2. If it's not, we'll throw an error back to the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yep we don't have anything to enforce this... the description will have to do ^^"

@jonathan-buttner jonathan-buttner merged commit 2c07f29 into main Mar 23, 2026
12 checks passed
@jonathan-buttner jonathan-buttner deleted the ia-azure-openai-headers branch March 23, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants