Problem/Motivation

Configuring the Azure AI Provider adding a chat model in the fieldset Model Data I'm asked to enter a Model ID.

The description for the field reads:

The model ID of the model you are using that you are using. This is for Drupal’s internals only and is not used with the provider. If no extra label is provided this will be the label.

So I input the value gpt_51_chat and fill our the rest of the form.

When I then try a chat request (via Field widget actions in my scenario) I get the following response:

Error invoking model response: Unknown model: gpt_51_chat

If I change the Model ID to the model ID as specified in Azure, gpt-5.1-chat, the chat request works as supposed.

Steps to reproduce

Se above.

Proposed resolution

Update the Model ID field description to make to user aware of the fact that the value will be used in requests to Azure. The value will be sent as part of the payload:

{ "messages" : [], "model": "<MODEL_ID>", ... }

Remaining tasks

Update field description.

User interface changes

None.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

peter törnstrand created an issue. See original summary.

peter törnstrand’s picture

I'm assigning myself as I intend to create a merge request for this issue.

peter törnstrand’s picture

Ok, so it seems this field is part of the AI module: Drupal\ai\OperationType\GenericType\AbstractModelFormBase. So the typo will have to be fixed in AI module repository and the description overridden for this module.

peter törnstrand’s picture

I suggest the following field description:

The model ID for the model you are using. This value is used to identify the model in requests to Azure, so make sure the model ID is entered in the correct format. If no additional label is provided, this value will also be used as the label.

peter törnstrand’s picture

Assigned: peter törnstrand » Unassigned
Status: Active » Needs review
peter törnstrand’s picture

I wonder if I might make another change to the field description of the Endpoint field as I was struggling to get the correct value for this field.

What I ended up with was https://<service name>.cognitiveservices.azure.com/openai/v1/chat/completions for a chat model.

Perhaps we could supply example values? I have seen the following URLs:

  • https://<service name>.cognitiveservices.azure.com/openai/v1/chat/completions
  • https://<service name>.openai.azure.com/openai/deployments//chat/completions?api-version=<api version>
  • https://<service name>.cognitiveservices.azure.com/openai/responses?api-version=<api version>

It's not really clear what version to use even though the description includes:

...its the endpoints with completions in the end you need to copy.

peter törnstrand’s picture

Assigned: Unassigned » peter törnstrand
Status: Needs review » Active

Ok, so this was not so simple as I thought. Entering a Model ID in the correct format for Azure results in form validation error when saving the model.

Model ID can only contain letters, numbers, hyphens and underscores.

peter törnstrand’s picture

Assigned: peter törnstrand » Unassigned
Status: Active » Needs review

Ok so I took a different approach instead. I added a new required field to the model config form, Model name with the following description:

The name of the model you are using. This value is used to identify the model in requests to Azure, so make sure the model name is entered in the correct format, for example gpt-5.1-chat.

marcus_johansson’s picture

marcus_johansson’s picture

Assigned: Unassigned » marcus_johansson

Reviewing

marcus_johansson’s picture

Assigned: marcus_johansson » Unassigned
Status: Needs review » Needs work

Needs a rebase and I added some comments.

joshua1234511’s picture

Assigned: Unassigned » joshua1234511
Status: Needs work » Active
joshua1234511’s picture

Assigned: joshua1234511 » Unassigned
Status: Active » Needs review
jhuhta’s picture

I actually bumped into the same problem while developing another feature, and without knowing about this issue, solved it differently, by adding a model override config field and not load the meaning of the model name field. Let's see if I get that feature pushed soon.

Edit: the feature in question is here: #3614660: Support the Responses API

marcus_johansson’s picture

Status: Needs review » Reviewed & tested by the community

LGTM now.

joshua1234511’s picture

Assigned: Unassigned » joshua1234511
joshua1234511’s picture

Assigned: joshua1234511 » Unassigned
Status: Reviewed & tested by the community » Fixed

@jhuhta, thanks for flagging. It's good to know we independently landed on the same root cause. This is merged now, so here's what's in there, in case it saves you work in #3614660:

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

arianraeesi’s picture

Status: Fixed » Closed (fixed)