openclaw - 💡(How to fix) Fix Support openai-chat API type for providers [2 comments, 2 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#55062Fetched 2026-04-08 01:33:02
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
commented ×2labeled ×1mentioned ×1subscribed ×1

Add openai-chat API type to support Chinese AI providers that only offer /v1/chat/completions endpoint

Error Message

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

Root Cause

Add openai-chat API type to support Chinese AI providers that only offer /v1/chat/completions endpoint

RAW_BUFFERClick to expand / collapse

Summary

Add openai-chat API type to support Chinese AI providers that only offer /v1/chat/completions endpoint

Problem to solve

Many Chinese AI API providers (e.g., ouyi) only support the /v1/chat/completions endpoint. OpenClaw currently lacks an openai-chat API type, only supporting openai-completions (legacy /v1/completions) which these providers reject with "Unknown parameter: max_completion_tokens".

Proposed solution

Add a new openai-chat API type that maps to /v1/chat/completions endpoint, similar to how openai-responses maps to /v1/responses. This enables OpenClaw to work with Chinese AI providers that only offer 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 /v1/chat/completions endpoint, we will introduce a new API type, openai-chat, which will map to this endpoint. Here are the steps to implement this fix:

  • Add a new constant for the openai-chat API type
  • Update the API endpoint mapping to include the new openai-chat type
  • Modify the request payload to conform to the /v1/chat/completions endpoint requirements

Example Code

# Add a new constant for the openai-chat API type
API_TYPES = {
    # ...
    'openai-chat': '/v1/chat/completions',
    # ...
}

# Update the API endpoint mapping
def get_api_endpoint(api_type):
    return API_TYPES.get(api_type)

# Modify the request payload
def prepare_request_payload(api_type, prompt, max_tokens):
    if api_type == 'openai-chat':
        return {
            'model': 'chat',
            'messages': [{'role': 'user', 'content': prompt}],
            'max_tokens': max_tokens,
        }
    # ...

Verification

To verify that the fix worked, you can test the new openai-chat API type by sending a request to the /v1/chat/completions endpoint with a valid payload. You should receive a successful response from the API provider.

Extra Tips

  • Make sure to update the documentation to reflect the new openai-chat API type and its usage.
  • Consider adding error handling for cases where the API provider returns an error 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