The format of the openrouter model access request has been changed #311

Closed
opened 2026-02-16 10:18:56 -05:00 by yindo · 2 comments
Owner

Originally created by @viereck-lan on GitHub (May 24, 2025).

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

1.4.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Image

✔️ Expected Behavior

Normal output

Actual Behavior

【错误信息: Dify 请求失败:Dify 出现错误 status: 400 message: Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [openrouter] Error: PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 404: {\"error\":{\"message\":\"No endpoints found that support tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing\",\"code\":404}}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 404: {\"error\":{\"message\":\"No endpoints found that support tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing\",\"code\":404}}"}"}】

API Error Issue Report

1. Basic Information

  • Error Date: May 24, 2025
  • Error Time: [Specific Time]
  • Environment: Production/Testing
  • System Version: Dify Platform [Version Number]
  • Related Services: OpenRouter API, Chutes Model Provider

2. Error Details

2.1 Error Message[AstrBot Request Failed.

Error Message: Dify Request Failed: Dify encountered an error with status: 400. Message: Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [openai_api_compatible] Error: PluginInvokeError: {"args":{"description":"[models] Error: API request failed with status code 400: {\"error\":{\"message\":\"\\\"functions\\\" and \\\"function_call\\\" are deprecated in favor of \\\"tools\\\" and \\\"tool_choice.\\\" To learn how to use tools, visit: https://openrouter.ai/docs/requests#tool-calls\",\"code\":400,\"metadata\":{\"provider_name\":\"Chutes\"}},\"user_id\":\"user_【The specific username is anonymous】\"}"},"error_type":"InvokeError","message":"[models] Error: API request failed with status code 400: {\"error\":{\"message\":\"\\\"functions\\\" and \\\"function_call\\\" are deprecated in favor of \\\"tools\\\" and \\\"tool_choice.\\\" To learn how to use tools, visit: https://openrouter.ai/docs/requests#tool-calls\",\"code\":400,\"metadata\":{\"provider_name\":\"Chutes\"}},\"user_id\":\"user_2uB4oix8NnIeNWA7yVKjfL5TWew\"}"}"}】

2.2 Error Type

  • HTTP Status Code: 400 Bad Request
  • Error Category: Deprecated Parameter Error

2.3 Root Cause

The API request used deprecated parameters in OpenRouter:

  • functions → Should be replaced with tools
  • function_call → Should be replaced with tool_choice

3. Impact Scope

  1. Functional Module: All AI assistant features calling OpenRouter API
  2. Affected Users: All users leveraging the Chutes model provider
  3. Business Impact: AI assistants fail to respond normally, degrading user experience

4. Error Analysis

4.1 Error Trigger Conditions

  • When the application sends requests containing functions or function_call parameters to OpenRouter
  • When utilizing services from the Chutes model provider

4.2 Technical Details

  • Parameter Structure Comparison:
    // Deprecated Version
    {
      "messages": [...],
      "functions": [
        {
          "name": "get_weather",
          "parameters": { ... }
        }
      ],
      "function_call": "auto"
    }
    
    // Updated Version
    {
      "messages": [...],
      "tools": [
        {
          "type": "function",  // New field
          "function": {
            "name": "get_weather",
            "parameters": { ... }
          }
        }
      ],
      "tool_choice": "auto"  // Parameter name changed
    }
    
  • Provider Policy: The Chutes model provider has fully removed support for deprecated parameters
Originally created by @viereck-lan on GitHub (May 24, 2025). ### 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 1.4.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce ![Image](https://github.com/user-attachments/assets/1a464521-7021-4717-bc9b-724cb577a8b8) ### ✔️ Expected Behavior Normal output ### ❌ Actual Behavior 【错误信息: Dify 请求失败:Dify 出现错误 status: 400 message: Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [openrouter] Error: PluginInvokeError: {\"args\":{\"description\":\"[models] Error: API request failed with status code 404: {\\\"error\\\":{\\\"message\\\":\\\"No endpoints found that support tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing\\\",\\\"code\\\":404}}\"},\"error_type\":\"InvokeError\",\"message\":\"[models] Error: API request failed with status code 404: {\\\"error\\\":{\\\"message\\\":\\\"No endpoints found that support tool use. To learn more about provider routing, visit: https://openrouter.ai/docs/provider-routing\\\",\\\"code\\\":404}}\"}"}】 # API Error Issue Report ## 1. Basic Information - **Error Date**: May 24, 2025 - **Error Time**: [Specific Time] - **Environment**: Production/Testing - **System Version**: Dify Platform [Version Number] - **Related Services**: OpenRouter API, Chutes Model Provider ## 2. Error Details ### 2.1 Error Message[AstrBot Request Failed. Error Message: Dify Request Failed: Dify encountered an error with status: 400. Message: Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [openai_api_compatible] Error: PluginInvokeError: {\"args\":{\"description\":\"[models] Error: API request failed with status code 400: {\\\"error\\\":{\\\"message\\\":\\\"\\\\\\\"functions\\\\\\\" and \\\\\\\"function_call\\\\\\\" are deprecated in favor of \\\\\\\"tools\\\\\\\" and \\\\\\\"tool_choice.\\\\\\\" To learn how to use tools, visit: https://openrouter.ai/docs/requests#tool-calls\\\",\\\"code\\\":400,\\\"metadata\\\":{\\\"provider_name\\\":\\\"Chutes\\\"}},\\\"user_id\\\":\\\"user_【The specific username is anonymous】\\\"}\"},\"error_type\":\"InvokeError\",\"message\":\"[models] Error: API request failed with status code 400: {\\\"error\\\":{\\\"message\\\":\\\"\\\\\\\"functions\\\\\\\" and \\\\\\\"function_call\\\\\\\" are deprecated in favor of \\\\\\\"tools\\\\\\\" and \\\\\\\"tool_choice.\\\\\\\" To learn how to use tools, visit: https://openrouter.ai/docs/requests#tool-calls\\\",\\\"code\\\":400,\\\"metadata\\\":{\\\"provider_name\\\":\\\"Chutes\\\"}},\\\"user_id\\\":\\\"user_2uB4oix8NnIeNWA7yVKjfL5TWew\\\"}\"}"}】 ### 2.2 Error Type - **HTTP Status Code**: 400 Bad Request - **Error Category**: Deprecated Parameter Error ### 2.3 Root Cause The API request used deprecated parameters in OpenRouter: - `functions` → Should be replaced with `tools` - `function_call` → Should be replaced with `tool_choice` ## 3. Impact Scope 1. **Functional Module**: All AI assistant features calling OpenRouter API 2. **Affected Users**: All users leveraging the Chutes model provider 3. **Business Impact**: AI assistants fail to respond normally, degrading user experience ## 4. Error Analysis ### 4.1 Error Trigger Conditions - When the application sends requests containing `functions` or `function_call` parameters to OpenRouter - When utilizing services from the Chutes model provider ### 4.2 Technical Details - **Parameter Structure Comparison**: ```json // Deprecated Version { "messages": [...], "functions": [ { "name": "get_weather", "parameters": { ... } } ], "function_call": "auto" } // Updated Version { "messages": [...], "tools": [ { "type": "function", // New field "function": { "name": "get_weather", "parameters": { ... } } } ], "tool_choice": "auto" // Parameter name changed } ``` - **Provider Policy**: The Chutes model provider has fully removed support for deprecated parameters
yindo added the good first issue label 2026-02-16 10:18:56 -05:00
yindo closed this issue 2026-02-16 10:18:56 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (May 24, 2025):

The error you are encountering is due to recent changes in the OpenRouter API: the parameters functions and function_call have been deprecated and replaced by tools and tool_choice. Requests using the old parameters now result in a 400 Bad Request error, and the Chutes model provider has fully removed support for the deprecated format.

How to update your API request format:

  • Old (Deprecated) Format:

    {
      "messages": [...],
      "functions": [
        {
          "name": "get_weather",
          "parameters": { ... }
        }
      ],
      "function_call": "auto"
    }
    
  • New (Required) Format:

    {
      "messages": [...],
      "tools": [
        {
          "type": "function",
          "function": {
            "name": "get_weather",
            "parameters": { ... }
          }
        }
      ],
      "tool_choice": "auto"
    }
    

Impact on Dify:

  • All AI assistant features in Dify that call the OpenRouter API and use the Chutes model provider are affected.
  • The error will persist until the request format is updated to use tools and tool_choice.

Relevant code and configuration:

  • Dify’s codebase already contains classes and methods related to tool invocation, such as in api/models/tools.py, which are relevant to the new parameters.
  • The model invocation logic in Dify (e.g., in the FunctionCallMultiDatasetRouter class) uses the tools parameter for LLM calls, which aligns with the new OpenRouter requirements. See example usage here.
  • Model configuration files for OpenRouter models (e.g., claude-3-opus.yaml) include features like tool-call and stream-tool-call, indicating support for the new tool invocation format.

What to do next:

  • Ensure your Dify installation and any custom code or plugins are updated to use the new tools and tool_choice parameters in all OpenRouter API requests.
  • If you are using an older version of Dify (such as 1.4.0), check if there are updates or patches available that address this change. No specific patch was found in the repository, so you may need to update your Dify version or manually adjust the relevant code to match the new API format.

If you need to update your code, focus on replacing any usage of functions/function_call with tools/tool_choice in the payloads sent to OpenRouter.

No official documentation or issue thread was found specifically addressing this migration, but the codebase and model configs confirm the new format is supported and required. If you need further guidance on where to make these changes in your setup, let me know which part of the code or workflow you are customizing.

To continue talking to Dosu, mention @dosu-bot.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (May 24, 2025): <!-- Answer --> The error you are encountering is due to recent changes in the OpenRouter API: the parameters `functions` and `function_call` have been deprecated and replaced by `tools` and `tool_choice`. Requests using the old parameters now result in a 400 Bad Request error, and the Chutes model provider has fully removed support for the deprecated format. **How to update your API request format:** - **Old (Deprecated) Format:** ```json { "messages": [...], "functions": [ { "name": "get_weather", "parameters": { ... } } ], "function_call": "auto" } ``` - **New (Required) Format:** ```json { "messages": [...], "tools": [ { "type": "function", "function": { "name": "get_weather", "parameters": { ... } } } ], "tool_choice": "auto" } ``` **Impact on Dify:** - All AI assistant features in Dify that call the OpenRouter API and use the Chutes model provider are affected. - The error will persist until the request format is updated to use `tools` and `tool_choice`. **Relevant code and configuration:** - Dify’s codebase already contains classes and methods related to tool invocation, such as in [`api/models/tools.py`](https://github.com/langgenius/dify/blob/main/api/models/tools.py), which are relevant to the new parameters. - The model invocation logic in Dify (e.g., in the `FunctionCallMultiDatasetRouter` class) uses the `tools` parameter for LLM calls, which aligns with the new OpenRouter requirements. See example usage [here](https://github.com/langgenius/dify/blob/main/api/core/rag/retrieval/router/multi_dataset_function_call_router.py). - Model configuration files for OpenRouter models (e.g., [`claude-3-opus.yaml`](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/openrouter/llm/claude-3-opus.yaml)) include features like `tool-call` and `stream-tool-call`, indicating support for the new tool invocation format. **What to do next:** - Ensure your Dify installation and any custom code or plugins are updated to use the new `tools` and `tool_choice` parameters in all OpenRouter API requests. - If you are using an older version of Dify (such as 1.4.0), check if there are updates or patches available that address this change. No specific patch was found in the repository, so you may need to update your Dify version or manually adjust the relevant code to match the new API format. If you need to update your code, focus on replacing any usage of `functions`/`function_call` with `tools`/`tool_choice` in the payloads sent to OpenRouter. No official documentation or issue thread was found specifically addressing this migration, but the codebase and model configs confirm the new format is supported and required. If you need further guidance on where to make these changes in your setup, let me know which part of the code or workflow you are customizing. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://go.dosu.dev/dosubot), mention @dosu-bot.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/dc1ae149-4a22-46f8-aba5-3ba8ab858836?feedback_type=other)</sup>
Author
Owner

@viereck-lan commented on GitHub (May 24, 2025):

dify and OpenRouter aly best new

@viereck-lan commented on GitHub (May 24, 2025): dify and OpenRouter aly best new
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#311