In the previous blog we got OpenClaw running in Docker. Now, we give it a brain and a voice. The brain is Claude via the Anthropic API. The voice is Telegram. By the end, you will be chatting with Clawde from your phone.
Here is the full stack we are building:
Telegram (your phone)
↓
@askclawde_bot (Telegram Bot)
↓
OpenClaw Gateway (Docker container)
↓
Claude via Anthropic API (the brain)
It is strongly recommended to create a dedicated API key for OpenClaw rather than reusing one from another project. This gives you:
- Blast radius control: if OpenClaw burns through credits unexpectedly, it won't affect your other projects
- Easy revocation: you can revoke OpenClaw's key without disrupting anything else
- Usage tracking: OpenClaw's usage shows up separately in the Anthropic console, making costs easy to monitor
- Security: if the key is ever exposed in logs or config files, the damage is contained
Go to console.anthropic.com, navigate to API Keys, and create a new key named clawde or openclaw-local.
Anthropic credit grants (free promotional credits) are not sufficient for API access: you must purchase credits directly. Go to API Keys → Billing → Buy credits and add a small amount (e.g. $5) with a credit card.
New accounts default to a $0 monthly spend limit, which blocks all API access regardless of your credit balance. Go to Limits and set it to a reasonable amount, e.g. $20 to match your purchased credits.
- Plans & Billing: confirm purchased credits are available (credit grants alone are not enough)
- Limits: confirm monthly limit is greater than $0
- API Keys → Last used at: shows
Neveruntil the first successful API call; use this to confirm the key is working
Run the following command to configure the Anthropic API key for the main agent:
docker exec -it openclaw node openclaw.mjs agents add mainThis will prompt you to select a model/auth provider: OpenClaw supports a wide range of providers including Anthropic, OpenAI, Google, Mistral, Ollama (fully local/offline), OpenRouter, and many more. Select Anthropic, then when prompted for the auth method choose Anthropic API key: this is the standard, long-lived credential from the Anthropic console. The "Anthropic token (setup-token)" option is a temporary token for device-based auth flows and adds unnecessary complexity for a self-hosted setup.
The key is stored in:
~/openclaw-config/agents/main/agent/auth-profiles.json
Because ~/openclaw-config is mounted as a volume, the key persists across container restarts.
Before testing via the chat UI, verify the API key works directly against the Anthropic API:
KEY=$(docker exec openclaw cat /home/node/.openclaw/agents/main/agent/auth-profiles.json | \
python3 -c "import sys,json; d=json.load(sys.stdin); print(list(d['profiles'].values())[0]['key'])")
curl -s https://api.anthropic.com/v1/messages \
-H "x-api-key: $KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-3-haiku-20240307","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}'A successful response will contain a content field. If you see "Your credit balance is too low", check that you have purchased credits and your monthly spend limit is greater than $0.
After configuring the API key, you can connect OpenClaw to a messaging platform. OpenClaw supports a wide range of channels including Telegram, WhatsApp, Discord, Slack, Signal, iMessage, Microsoft Teams, Matrix, and many more: OpenClaw can meet you wherever you already communicate.
In this blog we'll use Telegram: it's the easiest to set up and keeps your other personal accounts completely separate, limiting the blast radius if something goes wrong.
Open Telegram and search for @BotFather. Send it:
/newbot
BotFather will ask for:
- A display name: e.g.
Clawde - A username (must end in
bot): e.g.askclawde_bot
BotFather will then give you a bot token. Keep it handy.
Run the agents add main command again and this time select Telegram (Bot API) as the channel. Paste the bot token when prompted.
When asked about DM access policies, select No (default pairing policy is fine). When asked about routing bindings, select No.
docker exec -it openclaw node openclaw.mjs agents add mainOpen Telegram, search for your bot (e.g. @askclawde_bot), and tap Start. OpenClaw will respond with a pairing code:
OpenClaw: access not configured.
Your Telegram user id: <your-id>
Pairing code: XXXXXXXX
Ask the bot owner to approve with:
openclaw pairing approve telegram XXXXXXXX
Run the following command with the pairing code from Telegram:
docker exec openclaw node openclaw.mjs pairing approve telegram <pairing-code>
Send any message to the bot in Telegram: OpenClaw will now respond using Claude via the Anthropic API.
A simple weather question on Telegram cost $0.13. That may seem small, but it adds up quickly. What looks like a single question actually involves multiple exchanges: OpenClaw asks for your location, fetches the data, formats the response, and maintains conversation history all of which burn tokens.
OpenClaw defaults to anthropic/claude-opus-4-6, which is the most capable but also the most expensive Claude model. For everyday tasks like weather queries, switching to a smaller model can reduce costs significantly:
| Model | Best for |
|---|---|
claude-opus-4-6 |
Complex reasoning, coding, long documents |
claude-sonnet-4-6 |
Balanced performance and cost |
claude-haiku-4-5 |
Simple queries, fast responses, low cost |
To change the model, update openclaw.json:
{
"gateway": {
"bind": "lan",
"model": "anthropic/claude-sonnet-4-6"
}
}Or set it per agent when running agents add main. Match the model to the task not every question needs Opus.
OpenClaw is also accessible directly from the browser without any messaging app:
http://127.0.0.1:18789/chat?session=agent%3Amain%3Amain