Skip to content

[ML] AI/Inference Connector creation: use 'location' field to correctly set provider config #250838

Merged
alvarezmelissa87 merged 13 commits intoelastic:mainfrom
alvarezmelissa87:inference-connector-location-handling
Mar 18, 2026
Merged

[ML] AI/Inference Connector creation: use 'location' field to correctly set provider config #250838
alvarezmelissa87 merged 13 commits intoelastic:mainfrom
alvarezmelissa87:inference-connector-location-handling

Conversation

@alvarezmelissa87
Copy link
Copy Markdown
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Jan 28, 2026

Summary

Related issue: #241872

In upcoming changes, the services API will specify where a field should be included (service_settings or task_settings) - this will be an optional location field (similar to supported_task_types and how it's used). This will help Kibana build the request and place the fields in the correct settings object.

This PR ensures that field is used to set the config fields in the correct location - if the field is not present, then the default location should be service_settings.

This PR utilizes the existing but unused taskTypeConfig for keeping track of what fields end up going in task_settings. Anything in 'providerConfig' remains in service_settings.

The serializers have been updated to handle the old saved object format that didn't include taskTypeConfig.

Example of what the field will look like:

{
    "service": "openai",
    "name": "OpenAI",
    "task_types": [
        "text_embedding",
        "completion",
        "chat_completion"
    ],
    "configurations": {
        "api_key": {
            "description": "The OpenAI API authentication key. For more details about generating OpenAI API keys, refer to the https://platform.openai.com/account/api-keys.",
            "label": "API Key",
            "required": true,
            "sensitive": true,
            "updatable": true,
            "type": "str",
            "supported_task_types": [
                "text_embedding",
                "completion",
                "chat_completion"
            ]
        },
        "url": {
            "description": "The absolute URL of the external service to send requests to.",
            "label": "URL",
            "required": false,
            "sensitive": false,
            "updatable": false,
            "type": "str",
            "supported_task_types": [
                "text_embedding",
                "completion",
                "chat_completion"
            ],
         "location": a string either task_settings|service_settings 
        },
...
}

TESTING

To test, create a connector with Open AI as the provider (gpt-4.1 model id can be used) with custom headers on main (so the old saved object format is created) and create one on the branch to ensure both show up correctly. The same can be done for Anthropic (claude-sonnet-4-5 model id can be used) with max_tokens set.

For adaptive allocations, test on serverless and ensure that adaptive allocations are sent correctly for elastic/elasticsearch provider. On stateful it will be num_threads and num_allocations. You can create a connector/inference endpoint on main and then on the branch to ensure both show up correctly. Ping me if you need any api keys to use.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

@alvarezmelissa87 alvarezmelissa87 self-assigned this Jan 28, 2026
@alvarezmelissa87 alvarezmelissa87 added Feature: AI Infra Relating to the AI Assistant flow and any work impacting/involving the AI/Inference Connector v9.4.0 Feature:Inference UI ML Inference endpoints UI and AI connector release_note:enhancement labels Jan 28, 2026
@alvarezmelissa87 alvarezmelissa87 marked this pull request as ready for review January 28, 2026 23:29
@alvarezmelissa87 alvarezmelissa87 requested review from a team as code owners January 28, 2026 23:29
@alvarezmelissa87 alvarezmelissa87 added ci:project-deploy-elasticsearch Create an Elasticsearch Serverless project ci:project-deploy-observability Create an Observability project labels Jan 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@alvarezmelissa87 alvarezmelissa87 added the backport:skip This PR does not require backporting label Jan 28, 2026
Copy link
Copy Markdown
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

(on behalf of search-kibana, didn't full review)

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

};

const taskSettingsWithHeaders = {
...unflattenObject(config?.taskTypeConfig ?? {}), // TODO: confirm this unflatten is needed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this todo still needed?

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

This PR is blocked by this bug fix (#251357) that needs to go in first.

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Copy Markdown
Contributor

merge conflict between base and head

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/ml-ui (:ml)

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

Copy link
Copy Markdown
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

LGTM.

Tested using Anthropic (claude-sonnet-4-5) and Elasticsearch service - created on main and on the PR branch, and can view / edit connectors successfully when running on your PR branch.

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

@saikatsarkar056 - updated this with latest from main. Would you be up for giving this a test on review? 🙏

@saikatsarkar056
Copy link
Copy Markdown
Contributor

I did the following tests:

Test 1: OpenAI with Custom Headers

  1. Go to Stack Management > Connectors > Create Connector > AI/Inference
  2. Select OpenAI as the provider
  3. Set the URL to https://openrouter.ai/api/v1/chat/completions
  4. Set Model ID to openai/gpt-4.1
  5. Enter your OpenRouter API key
  6. Add a custom header (e.g. key: x-test, value: hello)
  7. Click Save
  8. In the Network tab, find the connector response
  9. Verify:
    • headers is inside taskTypeConfig (not providerConfig)
    • model_id, url are inside providerConfig
  10. Close and re-open the connector -- verify the header displays correctly

Test 2: Anthropic with max_tokens

  1. Create another AI/Inference connector
  2. Select Anthropic as the provider
  3. Set the URL to https://openrouter.ai/api/v1/messages
  4. Enter your OpenRouter API key
  5. Set max_tokens to 1024
  6. Click Save
  7. In the Network tab, find the connector response
  8. Verify:
    • max_tokens is inside taskTypeConfig (not providerConfig)
    • Other fields like model_id are inside providerConfig
  9. Close and re-open the connector -- verify max_tokens displays correctly

enabled: true,
min_number_of_allocations: MIN_ALLOCATIONS,
...(maxAllocations ? { max_number_of_allocations: maxAllocations } : {}),
...(max_number_of_allocations ? { max_number_of_allocations } : {}),
Copy link
Copy Markdown
Contributor

@saikatsarkar056 saikatsarkar056 Mar 12, 2026

Choose a reason for hiding this comment

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

max_number_of_allocations is already checked at line: 27. We can just put max_number_of_allocations here instead of ternary operation

Suggested change
...(max_number_of_allocations ? { max_number_of_allocations } : {}),
max_number_of_allocations,

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.

@saikatsarkar056 - good catch! Updated in e0e21e1

...restProviderConfig
} = providerConfig || {};

if (restProviderConfig) {
Copy link
Copy Markdown
Contributor

@saikatsarkar056 saikatsarkar056 Mar 12, 2026

Choose a reason for hiding this comment

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

I think after destructuring providerConfig || {}, restProviderConfig will be at least an empty object {} which is always truthy. Could you please verify whether this is true? I will try to test. In that case, we can never reach line 62: return data

const providerConfig = undefined;
const { a, ...rest } = providerConfig || {};

if (rest) {
  console.log('always reaches here:', rest);
} else {
  console.log('never reaches here');
}

output: "always reaches here:",  {}

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.

@saikatsarkar056 - thank you for taking a look 🙏 You're totally right! Good catch - updated in e0e21e1

@alvarezmelissa87
Copy link
Copy Markdown
Contributor Author

This has been updated with latest main and all comments have been addressed. I tested all cases with latest changes.
Would appreciate a final look/test. cc @saikatsarkar056, @qn895, @Samiul-TheSoccerFan

Copy link
Copy Markdown
Member

@qn895 qn895 left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Copy link
Copy Markdown
Contributor

@Samiul-TheSoccerFan Samiul-TheSoccerFan left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Mar 18, 2026

⏳ Build in-progress

Failed CI Steps

Test Failures

  • [job] [logs] Scout: [ observability / uptime ] plugin / local-stateful-classic - MonitorDetails - navigates to monitor details and displays ping data
  • [job] [logs] Scout: [ platform / dashboard-stateful-classic ] plugin / local-stateful-classic - Sync colors - should be possible to disable color sync

History

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit c462948 into elastic:main Mar 18, 2026
18 checks passed
@alvarezmelissa87 alvarezmelissa87 deleted the inference-connector-location-handling branch March 18, 2026 23:38
mbondyra added a commit to mbondyra/kibana that referenced this pull request Mar 19, 2026
…d_agent_navigation2

* commit '9289d6b5502db245e645e190b0246554396c6c20': (34 commits)
  [api-docs] 2026-03-19 Daily api_docs build (elastic#258471)
  [Shared UX][DateRangePicker] Missing parts (elastic#258229)
  [Dashboard] Keep pinned_panels separate in read response (elastic#258444)
  Move inheritance: true to top level in .coderabbit.yml (elastic#258461)
  [DOCS] 9.3.2 Kibana release notes (elastic#257332)
  adds routing accept metric attribute to the cps metric (elastic#258168)
  [ML] AI/Inference Connector creation: use 'location' field to correctly set provider config  (elastic#250838)
  [Lens] Add e2e test for legend list layout (elastic#258160)
  [SigEvents] Convert feature duplication evaluators to createPrompt pattern (elastic#256534)
  Add actionable-obs author to .coderabbit.yml (elastic#257922)
  [DOCS] 9.2.7 Kibana release notes (elastic#257331)
  Grant Serverless editor/viewer access to ES v2 indices (elastic#258384)
  [SigEvents][Evals] Rename terminology for KI features and KI queries (elastic#258361)
  [EDR Workflows][Osquery] Add shared table toolbar components and redesign saved queries list (elastic#258394)
  [Automatic Import V2] Upload samples using an existing index (elastic#258074)
  Add GET /inference_features route to expose feature registry (elastic#258044)
  fix additional fields not included (elastic#257625)
  [Discover] [Metrics] Add tier 2 journeys for Metrics in Discover E2E (elastic#255036)
  [Lens as code] Support correct X-Axis types in ES|QL visualizations (elastic#258159)
  Update APM (main) (elastic#254880)
  ...
flash1293 pushed a commit to flash1293/kibana that referenced this pull request Mar 19, 2026
…ly set provider config (elastic#250838)

## Summary

Related issue: elastic#241872 

In upcoming changes, the services API will specify where a field should
be included (`service_settings` or `task_settings`) - this will be an
optional `location` field (similar to `supported_task_types` and how
it's used). This will help Kibana build the request and place the fields
in the correct settings object.

This PR ensures that field is used to set the config fields in the
correct location - if the field is not present, then the default
location should be `service_settings`.

This PR utilizes the existing but unused `taskTypeConfig` for keeping
track of what fields end up going in task_settings. Anything in
'providerConfig' remains in service_settings.

The serializers have been updated to handle the old saved object format
that didn't include taskTypeConfig.

Example of what the field will look like:
```
{
    "service": "openai",
    "name": "OpenAI",
    "task_types": [
        "text_embedding",
        "completion",
        "chat_completion"
    ],
    "configurations": {
        "api_key": {
            "description": "The OpenAI API authentication key. For more details about generating OpenAI API keys, refer to the https://platform.openai.com/account/api-keys.",
            "label": "API Key",
            "required": true,
            "sensitive": true,
            "updatable": true,
            "type": "str",
            "supported_task_types": [
                "text_embedding",
                "completion",
                "chat_completion"
            ]
        },
        "url": {
            "description": "The absolute URL of the external service to send requests to.",
            "label": "URL",
            "required": false,
            "sensitive": false,
            "updatable": false,
            "type": "str",
            "supported_task_types": [
                "text_embedding",
                "completion",
                "chat_completion"
            ],
         "location": a string either task_settings|service_settings 
        },
...
}
```

### TESTING

To test, create a connector with Open AI as the provider (gpt-4.1 model
id can be used) with custom headers on main (so the old saved object
format is created) and create one on the branch to ensure both show up
correctly. The same can be done for Anthropic (claude-sonnet-4-5 model
id can be used) with max_tokens set.

For adaptive allocations, test on serverless and ensure that adaptive
allocations are sent correctly for elastic/elasticsearch provider. On
stateful it will be num_threads and num_allocations. You can create a
connector/inference endpoint on main and then on the branch to ensure
both show up correctly. Ping me if you need any api keys to use.



### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jeramysoucy pushed a commit to jeramysoucy/kibana that referenced this pull request Mar 26, 2026
…ly set provider config (elastic#250838)

## Summary

Related issue: elastic#241872 

In upcoming changes, the services API will specify where a field should
be included (`service_settings` or `task_settings`) - this will be an
optional `location` field (similar to `supported_task_types` and how
it's used). This will help Kibana build the request and place the fields
in the correct settings object.

This PR ensures that field is used to set the config fields in the
correct location - if the field is not present, then the default
location should be `service_settings`.

This PR utilizes the existing but unused `taskTypeConfig` for keeping
track of what fields end up going in task_settings. Anything in
'providerConfig' remains in service_settings.

The serializers have been updated to handle the old saved object format
that didn't include taskTypeConfig.

Example of what the field will look like:
```
{
    "service": "openai",
    "name": "OpenAI",
    "task_types": [
        "text_embedding",
        "completion",
        "chat_completion"
    ],
    "configurations": {
        "api_key": {
            "description": "The OpenAI API authentication key. For more details about generating OpenAI API keys, refer to the https://platform.openai.com/account/api-keys.",
            "label": "API Key",
            "required": true,
            "sensitive": true,
            "updatable": true,
            "type": "str",
            "supported_task_types": [
                "text_embedding",
                "completion",
                "chat_completion"
            ]
        },
        "url": {
            "description": "The absolute URL of the external service to send requests to.",
            "label": "URL",
            "required": false,
            "sensitive": false,
            "updatable": false,
            "type": "str",
            "supported_task_types": [
                "text_embedding",
                "completion",
                "chat_completion"
            ],
         "location": a string either task_settings|service_settings 
        },
...
}
```

### TESTING

To test, create a connector with Open AI as the provider (gpt-4.1 model
id can be used) with custom headers on main (so the old saved object
format is created) and create one on the branch to ensure both show up
correctly. The same can be done for Anthropic (claude-sonnet-4-5 model
id can be used) with max_tokens set.

For adaptive allocations, test on serverless and ensure that adaptive
allocations are sent correctly for elastic/elasticsearch provider. On
stateful it will be num_threads and num_allocations. You can create a
connector/inference endpoint on main and then on the branch to ensure
both show up correctly. Ping me if you need any api keys to use.



### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting ci:project-deploy-elasticsearch Create an Elasticsearch Serverless project ci:project-deploy-observability Create an Observability project Feature: AI Infra Relating to the AI Assistant flow and any work impacting/involving the AI/Inference Connector Feature:Inference UI ML Inference endpoints UI and AI connector :ml release_note:enhancement v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants