-
-
Notifications
You must be signed in to change notification settings - Fork 69.1k
openai-completions API type does not support tool calling with third-party OpenAI-compatible APIs #41328
Description
Bug Description
When using third-party OpenAI-compatible APIs (like Alibaba Cloud Bailian/Qwen) with the `openai-completions` API type, tool calling does not work. The model outputs tool commands in text format (e.g., ```bash code blocks) instead of actually invoking the tools.
Steps to Reproduce
-
Configure a third-party OpenAI-compatible API provider (e.g., Alibaba Cloud Bailian):
```json
{
"models": {
"providers": {
"bailian": {
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"apiKey": "your-api-key",
"models": [
{
"id": "qwen3-coder-plus",
"api": "openai-completions",
"compat": {
"supportsTools": true
}
}
]
}
}
}
}
``` -
Run: `openclaw agent --agent main --local -m "Use exec tool to run echo test"`
-
Observe that the model outputs ```bash exec --command="echo test"``` in text instead of actually calling the tool.
Verification
Direct curl request to Bailian API works correctly with tool calling:
```bash
curl -s "https://coding.dashscope.aliyuncs.com/v1/chat/completions"
-H "Authorization: Bearer $API_KEY"
-H "Content-Type: application/json"
-d '{
"model": "qwen3-coder-plus",
"messages": [{"role": "user", "content": "Check weather in Beijing"}],
"tools": [{"type": "function", "function": {"name": "get_weather", "parameters": {...}}}]
}'
```
Returns: `"finish_reason":"tool_calls"` with proper tool call response.
Environment
- OpenClaw: 2026.3.8 (3caab92)
- Node.js: v24.14.0
- Platform: Linux (WSL2)
Root Cause
The `openai-completions` API type does not properly send tool definitions to the model, even when `compat.supportsTools: true` is configured.
Suggested Fix
- Add a new API type `openai-chat` that explicitly uses `/v1/chat/completions` endpoint with proper tool calling support.
- Or fix `openai-completions` to properly handle tool definitions for OpenAI-compatible APIs.