#How to control the amount of tokens I'm consuming from OpenAI API key?
25 messages Β· Page 1 of 1 (latest)
Short version: monitor in OpenClaw, reduce per-request usage, and set the real hard cap in OpenAI.
Fastest knobs:
/usage fullor/usage tokens
Shows tokens on each reply./status
Shows current session usage and estimated cost./context list
Shows what is bloating the prompt./compact
Shrinks long sessions.
Biggest ways to reduce spend:
- lower thinking, for example
/think offor/think low - switch to a cheaper/smaller model
- cap reply length with model params
maxTokens - keep sessions shorter / compact more often
- if you send lots of screenshots, lower
agents.defaults.imageMaxDimensionPx
Config example:
{
agents: {
defaults: {
thinkingDefault: "off",
models: {
"openai/<your-model>": {
params: {
maxTokens: 800
}
}
}
}
}
}
A useful distinction:
params.maxTokens= caps reply/output sizecontextTokens= caps how much prompt/history OpenClaw sends at runtime
Also, I do not think OpenClaw currently has a global βstop after N OpenAI tokensβ switch for an API key. For a true hard limit, set a project/key budget in the OpenAI dashboard too.
Docs:
- https://docs.openclaw.ai/concepts/context
- https://docs.openclaw.ai/tools/thinking
- https://docs.openclaw.ai/concepts/compaction
- https://docs.openclaw.ai/providers/openai
If you want, paste openclaw --version and your current model config, and I can suggest a tighter config snippet for your setup.
Sessions
βββββββββββββββββββββββββββββββββββββββββββββββββββββ¬βββββββββ¬ββββββββββ¬βββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β Key β Kind β Age β Model β Tokens β
βββββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββΌββββββββββΌβββββββββββββββΌβββββββββββββββββββββββββββββββββ€
β agent:main:telegram:direct:8469β¦ β direct β 3m ago β gpt-5.4 β 30k/200k (15%) Β· ποΈ 99% cached β
β agent:main:main β direct β 43m ago β gpt-5.4 β 16k/200k (8%) β
β agent:reverser:subagent:7e32b89β¦ β direct β 43m ago β gpt-5.4 β 9.5k/200k (5%) β
β agent:main:telegram:slash:84694β¦ β direct β 53m ago β gpt-5.4 β unknown/200k (?%) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββ΄βββββββββ΄ββββββββββ΄βββββββββββββββ΄βββββββββββββββββββββββββββββββββ
using Telegram consumes more tokens than direct chat?
Not inherently, no.
What your table shows is mostly different sessions, not βTelegram is expensiveβ:
agent:main:telegram:direct:...is one sessionagent:main:mainis anotheragent:main:telegram:slash:...is yet another- subagents always have their own context too
So if the Telegram session has more back-and-forth, tool output, media, or older history, it will show more tokens.
Also, this part matters a lot:
30k/200k ... ποΈ 99% cached
That means most of that Telegram prompt was cache-read, so the raw token count looks big, but the actual cost hit is much smaller than 30k fully-uncached tokens.
So the answer is basically:
- Telegram itself: usually not meaningfully more tokens
- A separate Telegram session with more history/context: yes, that can show higher usage
If you want to compare properly, run these in both chats:
/status/context list/usage full
If you want to reduce the Telegram one specifically, easiest fixes are:
/compact- start a fresh session if the thread got long
- lower thinking with
/think offor/think low
Docs:
Glad that helped! π
If this fixed it, please right-click the solution message β Apps β β
Mark Solution.
This helps Answer Overflow index the solution for future users.
how to check if the agent is still working or it's been stuck? he told me some time ago "Iβll update you as soon as the delegated checks come back" but no reply
Yep, you can check that.
If it said βdelegated checksβ, that was probably a sub-agent or another background task.
Use these:
/tasks
Shows active/recent background tasks for this session./subagents list
Shows delegated sub-agents for the current session./subagents info <id>
Shows status, timestamps, session id, etc./subagents log <id>
Shows recent output so you can see whether it is progressing or stuck./status
Gives a quick task summary too.
If it really is hung:
/stopfor the current foreground run/subagents kill <id>or/subagents kill allfor delegated ones
If /tasks and /subagents list both show nothing, then it likely already died, timed out, or the completion update failed to post back.
Docs:
- https://docs.openclaw.ai/automation/tasks
- https://docs.openclaw.ai/tools/subagents
- https://docs.openclaw.ai/tools/slash-commands
If you paste /tasks or /subagents list, I can help read it.
i want to change from GPT-5.4 to GPT-5.4 mini
Yep, easiest on Discord is just:
/model
That opens the picker. Choose the mini entry there.
Useful variants:
/model listto see what is available/model <exact-provider/model-ref>if you know the exact ref/model statusto confirm what the session is using now
Important difference:
- Only this current session: use
/model - Make it the default for new sessions too: change
agents.defaults.model.primaryor run:openclaw models set <provider/model>
If /model says the mini model is not allowed, it means it is not in your configured model allowlist (agents.defaults.models) yet.
Docs:
If the picker does not show it, paste:
openclaw --version/model list
and I can help with the exact next step.
I only see 5.4 but not 5.4 mini
Then I would not guess the model id.
If it is not in /model, it usually means one of these:
- your current OpenClaw version does not know about it yet
- it is not in your
agents.defaults.modelsallowlist - your current provider/account setup does not expose it
Please paste these:
openclaw --version
openclaw models status
openclaw models list --provider openai
If you only want the current chat-side view too, also paste:
/model list/model status
Once we see that, we can tell whether this is a version/catalog issue or just an allowlist/config issue.
Docs:
I think it's the same model 5.4 but it has 3 variants
Could be, yeah, but the key thing is this:
OpenClaw switches by the exact configured model ref, not by the marketing family name.
So if /model only shows one 5.4 entry, then from OpenClawβs point of view you currently have only one selectable 5.4 ref available in your catalog/allowlist.
So the other βvariantsβ might:
- exist on OpenAIβs side
- exist in a newer OpenClaw catalog
- or just not be exposed in your current config
That is why Iβd still verify instead of guessing the ref.
Please paste:
openclaw --version
openclaw models list --provider openai
openclaw models status
If your goal is just lower cost right now, even before sorting out variants, the quickest win is:
/think off- or cap output with
maxTokens
Docs:
Someone just posted about ANVX (https://clawhub.ai/tje8x/anvx) - I just downloaded and it seems pretty helpful!