When I configure OpenAI-API-compatible, I get an error when I add the o1-mini model #5723

Closed
opened 2026-02-21 18:12:19 -05:00 by yindo · 2 comments
Owner

Originally created by @skywolf123 on GitHub (Sep 22, 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.8.3

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

When I configure OpenAI-API-compatible, I get an error when I add the o1-mini model.

Because my o1-mini proxy is different from the gpt-4o proxy, I need to configure it through OpenAI-API-compatible, but the configuration can be used but the error is reported, and when I configure the o1-mini proxy to the OpenAI channel, it is normal, indicating that the configuration of OpenAI's o1-mini and OpenAI-API-compatible channels is different. How do I configure it to use o1-mini in OpenAI-API-compatible?

The following error message is displayed:

[openai_api_compatible] Error: API request failed with status code 400: {"error":{"message":"Unsupported value: 'stream' does not support true with this model. Only the default (false) value is supported. (request id: 202409210905172535451920nkD7l6j) (request id: 20240921210516980735533ipJvo1yK) (request id: 20240921210516931134794Yvyhulv4) (request id: 2024092121051685044612833J0l3AL)","type":"invalid_request_error","param":"stream","code":"unsupported_value"}}

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @skywolf123 on GitHub (Sep 22, 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.8.3 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce When I configure OpenAI-API-compatible, I get an error when I add the o1-mini model. Because my o1-mini proxy is different from the gpt-4o proxy, I need to configure it through OpenAI-API-compatible, but the configuration can be used but the error is reported, and when I configure the o1-mini proxy to the OpenAI channel, it is normal, indicating that the configuration of OpenAI's o1-mini and OpenAI-API-compatible channels is different. How do I configure it to use o1-mini in OpenAI-API-compatible? The following error message is displayed: ``` [openai_api_compatible] Error: API request failed with status code 400: {"error":{"message":"Unsupported value: 'stream' does not support true with this model. Only the default (false) value is supported. (request id: 202409210905172535451920nkD7l6j) (request id: 20240921210516980735533ipJvo1yK) (request id: 20240921210516931134794Yvyhulv4) (request id: 2024092121051685044612833J0l3AL)","type":"invalid_request_error","param":"stream","code":"unsupported_value"}} ``` ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 18:12:19 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 22, 2024):

To resolve the error "Unsupported value: 'stream' does not support true with this model" when configuring the o1-mini model using the OpenAI-API-compatible interface, you need to set the stream parameter to False. Here is an example of how to configure it:

from core.model_runtime.model_providers.openai_api_compatible.llm.llm import OAIAPICompatLargeLanguageModel
from core.model_runtime.entities.message_entities import SystemPromptMessage, UserPromptMessage
import os

model = OAIAPICompatLargeLanguageModel()

response = model.invoke(
    model="o1-mini",
    credentials={
        "api_key": os.environ.get("YOUR_API_KEY"),
        "endpoint_url": "https://api.yourprovider.com/v1/",
        "mode": "completion",
    },
    prompt_messages=[
        SystemPromptMessage(
            content="You are a helpful AI assistant.",
        ),
        UserPromptMessage(content="Who are you?"),
    ],
    model_parameters={
        "temperature": 1.0,
        "top_k": 2,
        "top_p": 0.5,
    },
    stop=["How"],
    stream=False,  # Ensure stream is set to False
    user="abc-123",
)

assert isinstance(response, LLMResult)
assert len(response.message.content) > 0

Make sure to replace "YOUR_API_KEY" and "https://api.yourprovider.com/v1/" with your actual API key and endpoint URL.

Additionally, ensure that the model's YAML configuration file defines the stream parameter correctly. The stream parameter should default to True, but you can override it by setting it to False in your invocation [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Sep 22, 2024): <!-- Answer --> To resolve the error "Unsupported value: 'stream' does not support true with this model" when configuring the `o1-mini` model using the OpenAI-API-compatible interface, you need to set the `stream` parameter to `False`. Here is an example of how to configure it: ```python from core.model_runtime.model_providers.openai_api_compatible.llm.llm import OAIAPICompatLargeLanguageModel from core.model_runtime.entities.message_entities import SystemPromptMessage, UserPromptMessage import os model = OAIAPICompatLargeLanguageModel() response = model.invoke( model="o1-mini", credentials={ "api_key": os.environ.get("YOUR_API_KEY"), "endpoint_url": "https://api.yourprovider.com/v1/", "mode": "completion", }, prompt_messages=[ SystemPromptMessage( content="You are a helpful AI assistant.", ), UserPromptMessage(content="Who are you?"), ], model_parameters={ "temperature": 1.0, "top_k": 2, "top_p": 0.5, }, stop=["How"], stream=False, # Ensure stream is set to False user="abc-123", ) assert isinstance(response, LLMResult) assert len(response.message.content) > 0 ``` Make sure to replace `"YOUR_API_KEY"` and `"https://api.yourprovider.com/v1/"` with your actual API key and endpoint URL. Additionally, ensure that the model's YAML configuration file defines the `stream` parameter correctly. The `stream` parameter should default to `True`, but you can override it by setting it to `False` in your invocation <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/tests/integration_tests/model_runtime/openai_api_compatible/test_llm.py)</sup><sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/guides/model-configuration/interfaces.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Sep 22, 2024):

Duplicated https://github.com/langgenius/dify/issues/8615

OpenAI's new models indeed have this issue. Currently, we only have the resources to maintain official mainstream model providers. For compatibility modes, we hope the community can contribute PRs. Additionally, our page uses default streaming output, so it doesn't support the statement mentioned in the previous issue.

@crazywoola commented on GitHub (Sep 22, 2024): Duplicated https://github.com/langgenius/dify/issues/8615 OpenAI's new models indeed have this issue. Currently, we only have the resources to maintain official mainstream model providers. For compatibility modes, we hope the community can contribute PRs. Additionally, our page uses default streaming output, so it doesn't support the statement mentioned in the previous issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#5723