openclaw - 💡(How to fix) Fix [API] Expose underlying model name in /v1/chat/completions response [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#55450Fetched 2026-04-08 01:39:25
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Fix Action

Fix / Workaround

Current Workaround

Code Example

{
  "id": "chatcmpl_abc123",
  "model": "anthropic/claude-sonnet-4-6",
  "choices": [...]
}
RAW_BUFFERClick to expand / collapse

Problem

Currently the OpenClaw OpenAI-compatible API returns "model": "openclaw" in all chat completion responses, regardless of the actual underlying model being used (e.g. anthropic/claude-sonnet-4-6, ollama/mistral, etc.).

Request

Expose the actual model identifier in the response — either:

  • As the model field in the response body (e.g. "model": "anthropic/claude-sonnet-4-6")
  • Or as a response header like X-OpenClaw-Model: anthropic/claude-sonnet-4-6

Use Case

Third-party clients (like KClaw, a voice iOS client for OpenClaw) want to display the active model to the user. Without this, clients must resort to hacks like sending a probe message asking the agent to self-identify — which wastes tokens and adds latency on every connection.

The model field in the OpenAI spec is intended to convey what model was used — returning "openclaw" breaks that contract for clients that care about model transparency.

Current Workaround

We currently send a silent system prompt on connect asking the agent to respond with MODEL:<model_name> and parse the reply. It works but it's a hack — a proper API field would be far cleaner.

Expected Behavior

{
  "id": "chatcmpl_abc123",
  "model": "anthropic/claude-sonnet-4-6",
  "choices": [...]
}

extent analysis

Fix Plan

To expose the actual model identifier in the response, we will modify the API to include the model field with the actual model name. Here are the steps:

  • Update the response generation code to include the actual model name in the model field.
  • Alternatively, add a response header X-OpenClaw-Model with the actual model name.

Example Code

# Assuming a Python backend using Flask
from flask import jsonify

# Get the actual model name from the underlying model
actual_model_name = get_actual_model_name()  # implement this function to get the model name

# Update the response to include the actual model name
response = {
    "id": "chatcmpl_abc123",
    "model": actual_model_name,  # use the actual model name here
    "choices": [...]
}

# Return the response as JSON
return jsonify(response)

# Alternatively, add a response header with the actual model name
response.headers["X-OpenClaw-Model"] = actual_model_name

Verification

To verify that the fix worked, test the API with different models and check that the model field in the response contains the correct model name. You can also check the response headers for the X-OpenClaw-Model header.

Extra Tips

  • Make sure to update the API documentation to reflect the change in the response format.
  • Consider adding a fallback or default value for the model field in case the actual model name is not available.
  • Test the API with different clients, including KClaw, to ensure that they can handle the updated response format correctly.

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 [API] Expose underlying model name in /v1/chat/completions response [1 participants]