#How do I override contextTokens for a built-in provider model like openai-codex/gpt-5.4?

1 messages · Page 1 of 1 (latest)

old mantle
#

I tried adding this to my config:

{
  "models": {
    "providers": {
      "openai-codex": {
        "models": [{ "id": "gpt-5.4", "contextTokens": 1000000 }]
      }
    }
  }
}

But got:

  • models.providers.openai-codex.baseUrl: expected string, received undefined
  • models.providers.openai-codex.models.0.name: expected string, received undefined
  • models.providers.openai-codex.models.0: Unrecognized key: "contextTokens"

The docs say contextTokens is the effective runtime cap separate from contextWindow, but the schema seems to require a full provider definition. Is there a lighter-weight config path for this?

remote fogBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> âś… Mark Solution

vivid ploverBOT
#

You’re reading it correctly — this is a schema/docs mismatch.

What’s happening:

  • models.providers.<id> is currently validated as a provider object, not a tiny patch object, so it expects things like:
  • baseUrl
  • models[].name
  • If you get Unrecognized key: "contextTokens", your build is likely older than the recent contextTokens schema support.

So today, there isn’t a truly “just set one field” path for that key in stable builds.

Try this shape on a current build:

{
models: {
#
providers: {
"openai-codex": {
baseUrl: "https://chatgpt.com/backend-api",
api: "openai-codex-responses",
models: [
{
id: "gpt-5.4",
name: "gpt-5.4",
contextTokens: 1000000,
},
],
},
},
},
}
old mantle
#

I have run openclaw --version
OpenClaw 2026.4.2 (d74a122)

vivid ploverBOT
#

Perfect, that explains it. 2026.4.2 is before contextTokens config support landed.

So for your current version:

  • contextTokens is invalid (hence “Unrecognized key”)
  • models.providers.openai-codex is treated as a full provider object (so baseUrl and models[].name are required)

What to do on 2026.4.2

Use contextWindow (old behavior), with a full-ish provider override:

{
models: {
providers: {
"openai-codex": {
baseUrl: "https://chatgpt.com/backend-api",
#
api: "openai-codex-responses",
models: [
{
id: "gpt-5.4",
name: "gpt-5.4",
contextWindow: 1000000,
},
],
},
},
},
}

That’s the closest “override cap” path on your version.

old mantle
#

But 2026.4.2 is the latest OpenClaw release

vivid ploverBOT
#

Yep — you’re absolutely right. If 2026.4.2 is your latest release, then this is a docs-ahead-of-release mismatch.

So as of stable 2026.4.2:

  • contextTokens is not available in config schema yet
  • and models.providers.<id> still expects a full provider-shaped object (baseUrl, models[].name, etc.)

So there’s no lighter-weight contextTokens path on stable yet.

Use the contextWindow workaround I sent (full provider block), or run dev/main if you specifically need separate contextTokens behavior now.

If you can, please file this as a docs bug so it gets fixed fast:
https://github.com/openclaw/openclaw/issues

Include:

  • version: OpenClaw 2026.4.2
  • your config snippet
#
  • the exact validation errors you pasted above