openclaw - 💡(How to fix) Fix [Feature]:Support openai-chat API type for providers [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#55059Fetched 2026-04-08 01:33:06
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Support openai-chat API type for providers

Error Message

Severity: Blocks workflow — providers return "Unknown parameter: max_completion_tokens" error

Root Cause

Support openai-chat API type for providers

RAW_BUFFERClick to expand / collapse

Summary

Support openai-chat API type for providers

Problem to solve

Many Chinese AI API providers (e.g., ouyi) only support /v1/chat/completions, not the legacy /v1/completions endpoint. OpenClaw has no openai-chat type.

Proposed solution

Add a new openai-chat API type that maps to /v1/chat/completions endpoint, enabling OpenClaw to work with Chinese API providers that only support chat completions format.

Alternatives considered

No response

Impact

Affected: Users of Chinese AI API providers (ouyi, DashScope, etc.) Severity: Blocks workflow — providers return "Unknown parameter: max_completion_tokens" error Frequency: Always when trying to use these providers as fallback Consequence: Cannot use free/cheap Chinese AI models as fallback, increases cost by relying only on paid MiniMax or local Ollama

Evidence/examples

No response

Additional information

No response

extent analysis

Fix Plan

To add support for the openai-chat API type, follow these steps:

  • Create a new API type in OpenClaw that maps to the /v1/chat/completions endpoint.
  • Update the API request payload to conform to the chat completions format.
  • Handle the response from the /v1/chat/completions endpoint.

Example code snippet in Python:

import requests

class OpenAIChatAPI:
    def __init__(self, api_url, api_key):
        self.api_url = api_url
        self.api_key = api_key

    def chat_completions(self, prompt, max_tokens):
        url = f"{self.api_url}/v1/chat/completions"
        headers = {
            "Authorization": f"Bearer {self.api_key}",
            "Content-Type": "application/json"
        }
        data = {
            "model": "your_model_name",
            "messages": [{"role": "user", "content": prompt}],
            "max_tokens": max_tokens
        }
        response = requests.post(url, headers=headers, json=data)
        return response.json()

# Example usage:
api = OpenAIChatAPI("https://api.example.com", "your_api_key")
response = api.chat_completions("Your prompt here", 1024)
print(response)

Verification

To verify that the fix worked, test the new API type with a Chinese AI provider that only supports the /v1/chat/completions endpoint. Check that the response from the API is correctly parsed and that the max_tokens parameter is no longer causing an error.

Extra Tips

  • Make sure to update the API documentation to reflect the new API type and endpoint.
  • Consider adding error handling for cases where the API provider returns an error or invalid response.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Feature]:Support openai-chat API type for providers [1 participants]