Error when trying to register o1-preview for Azure Open AI. #5933

Closed
opened 2026-02-21 18:13:18 -05:00 by yindo · 3 comments
Owner

Originally created by @osuta1010 on GitHub (Oct 7, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.9.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Error when adding model in Azure OpenAI Service

When navigating to Settings -> Model Providers -> Azure OpenAI Service -> Add Model, after entering values like Deployment Name, and pressing the Save button, the following error occurred:

Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}

Entered Parameters:

  • Model Type: LLM
  • Deployment Name: My resource
  • API Endpoint URL: My resource
  • API Key: My resource
  • API Version: 2024-08-01-preview
  • Base Model: gpt-4o
    fig1-1

✔️ Expected Behavior

  • It is now possible to add o1-preview in Azure OpenAI Service.

The normal response was confirmed to be returned with this code.

Dependency: openai==1.29.0

from openai import AzureOpenAI, Stream

import os
os.environ["OPENAI_API_VERSION"] = "2024-08-01-preview"
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://sample.openai.azure.com/"
os.environ["AZURE_OPENAI_API_KEY"] = "xxxxx"

client = AzureOpenAI()

print(client.chat.completions.create(
                    messages=[{"role": "user", "content": "ping"}],
                    model="o1-preview-model",
                    stream=False,
                )
)

Actual Behavior

An error occurred, and it was not added.

Originally created by @osuta1010 on GitHub (Oct 7, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.9.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ## Error when adding model in Azure OpenAI Service When navigating to **Settings -> Model Providers -> Azure OpenAI Service -> Add Model**, after entering values like Deployment Name, and pressing the Save button, the following error occurred: `Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}` ### Entered Parameters: - **Model Type**: LLM - **Deployment Name**: My resource - **API Endpoint URL**: My resource - **API Key**: My resource - **API Version**: 2024-08-01-preview - **Base Model**: gpt-4o ![fig1-1](https://github.com/user-attachments/assets/c1712a2f-7326-4247-a376-50169aab8e30) ### ✔️ Expected Behavior - It is now possible to add `o1-preview` in Azure OpenAI Service. The normal response was confirmed to be returned with this code. Dependency: `openai==1.29.0` ```python: from openai import AzureOpenAI, Stream import os os.environ["OPENAI_API_VERSION"] = "2024-08-01-preview" os.environ["AZURE_OPENAI_ENDPOINT"] = "https://sample.openai.azure.com/" os.environ["AZURE_OPENAI_API_KEY"] = "xxxxx" client = AzureOpenAI() print(client.chat.completions.create( messages=[{"role": "user", "content": "ping"}], model="o1-preview-model", stream=False, ) ) ``` ### ❌ Actual Behavior An error occurred, and it was not added.
yindo closed this issue 2026-02-21 18:13:18 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 7, 2024):

Hey there, @osuta1010! 👋 I'm here to assist you with bug fixes, answer your questions, and guide you on becoming a contributor.

The error you're encountering is due to the use of the max_tokens parameter, which is not supported for the model you're trying to register. Instead, you should use the max_completion_tokens parameter. This issue arises because the model you're working with requires a different parameter for specifying the maximum number of tokens.

To resolve this, you need to ensure that the parameter mapping in your configuration or code uses max_completion_tokens instead of max_tokens. This might involve updating the code where the parameters are set or modifying the configuration in the Dify platform to align with the requirements of the Azure OpenAI Service for the specific model version you're using.

If you're modifying the code directly, look for where the parameters are being set and ensure that max_completion_tokens is used in place of max_tokens. If this is a configuration issue within the Dify platform, you may need to adjust the settings in the interface where you add the model.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 7, 2024): <!-- Greeting --> Hey there, @osuta1010! 👋 I'm here to assist you with bug fixes, answer your questions, and guide you on becoming a contributor. <!-- Answer --> The error you're encountering is due to the use of the `max_tokens` parameter, which is not supported for the model you're trying to register. Instead, you should use the `max_completion_tokens` parameter. This issue arises because the model you're working with requires a different parameter for specifying the maximum number of tokens. To resolve this, you need to ensure that the parameter mapping in your configuration or code uses `max_completion_tokens` instead of `max_tokens`. This might involve updating the code where the parameters are set or modifying the configuration in the Dify platform to align with the requirements of the Azure OpenAI Service for the specific model version you're using. If you're modifying the code directly, look for where the parameters are being set and ensure that `max_completion_tokens` is used in place of `max_tokens`. If this is a configuration issue within the Dify platform, you may need to adjust the settings in the interface where you add the model. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@osuta1010 commented on GitHub (Oct 7, 2024):

@dosu
Hi dosu

Thank you for your reply.

I think you are correct.
https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=python-output#o1-preview-and-o1-mini-models-limited-access

You can read more about it here, but we need to use max_completion_tokens instead of max_tokens because the parameter has changed.

This requires changes not only to the registration code, but also to the runtime code.
Also temperature and top_p need to be set to 1.
If different values are used, a 400 error will be generated.

If this is not a problem, would you like me to create a pull request for you?

Thank you.

@osuta1010 commented on GitHub (Oct 7, 2024): @dosu Hi dosu Thank you for your reply. I think you are correct. https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=python-output#o1-preview-and-o1-mini-models-limited-access You can read more about it here, but we need to use `max_completion_tokens` instead of `max_tokens` because the parameter has changed. This requires changes not only to the registration code, but also to the runtime code. Also `temperature` and `top_p` need to be set to 1. If different values are used, a 400 error will be generated. If this is not a problem, would you like me to create a pull request for you? Thank you.
Author
Owner

@dosubot[bot] commented on GitHub (Oct 7, 2024):

It sounds like you've identified the necessary changes to resolve the issue. Since the parameters have changed, updating both the registration and runtime code to use max_completion_tokens and setting temperature and top_p to 1 is essential. If you're comfortable with making these changes, creating a pull request would be a great way to contribute to the repository. Your efforts to align the code with the updated Azure OpenAI requirements will be valuable. Thank you for your initiative!

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 7, 2024): <!-- Answer --> It sounds like you've identified the necessary changes to resolve the issue. Since the parameters have changed, updating both the registration and runtime code to use `max_completion_tokens` and setting `temperature` and `top_p` to 1 is essential. If you're comfortable with making these changes, creating a pull request would be a great way to contribute to the repository. Your efforts to align the code with the updated Azure OpenAI requirements will be valuable. Thank you for your initiative! <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5933