mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-22 01:55:27 -04:00
The format of the openrouter model access request has been changed #311
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @viereck-lan on GitHub (May 24, 2025).
Self Checks
Dify version
1.4.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
✔️ 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
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
2.3 Root Cause
The API request used deprecated parameters in OpenRouter:
functions→ Should be replaced withtoolsfunction_call→ Should be replaced withtool_choice3. Impact Scope
4. Error Analysis
4.1 Error Trigger Conditions
functionsorfunction_callparameters to OpenRouter4.2 Technical Details
@dosubot[bot] commented on GitHub (May 24, 2025):
The error you are encountering is due to recent changes in the OpenRouter API: the parameters
functionsandfunction_callhave been deprecated and replaced bytoolsandtool_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:
New (Required) Format:
Impact on Dify:
toolsandtool_choice.Relevant code and configuration:
api/models/tools.py, which are relevant to the new parameters.FunctionCallMultiDatasetRouterclass) uses thetoolsparameter for LLM calls, which aligns with the new OpenRouter requirements. See example usage here.claude-3-opus.yaml) include features liketool-callandstream-tool-call, indicating support for the new tool invocation format.What to do next:
toolsandtool_choiceparameters in all OpenRouter API requests.If you need to update your code, focus on replacing any usage of
functions/function_callwithtools/tool_choicein 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
@viereck-lan commented on GitHub (May 24, 2025):
dify and OpenRouter aly best new