OpenClaw integration
Use Plan2API as a custom provider in OpenClaw
OpenClaw takes Plan2API as 1 custom provider entry in ~/.openclaw/openclaw.json: baseUrl https://api.plan2api.com/v1, api openai-completions and a p2a_ key. Set the primary model to plan2api/claude/claude-sonnet-5 and your Claude, ChatGPT, Gemini or Kimi plan runs the agent, with 50 free chat requests a day.
- Config file
- ~/
.openclaw/ openclaw.json - api
- openai-completions
- Model ref format
- plan2api/
<Plan2API model id> - Free plan
- 50 chat requests a day
Updated
OpenClaw settings for Plan2API
OpenClaw talks to Plan2API as a custom provider that uses the OpenAI-compatible Chat Completions format, set up in its config file. The table below lists the values to put in your config.
| Setting | Value |
|---|---|
| Config file | ~/ |
| Provider entry | models.providers.plan2api |
| baseUrl | https:// |
| apiKey | ${PLAN2API_ |
| api | openai-completions |
| models[].id | A Plan2API id, such as claude/ |
| Default model | agents.defaults.model.primary |
| Model ref | plan2api/ |
When Plan2API helps in OpenClaw
OpenClaw already signs in to ChatGPT and Codex with OAuth, reuses a local Claude CLI login (and setup-token auth still works), and takes Anthropic, Google AI Studio, Vertex AI and Kimi API keys. However, it doesn't create Gemini CLI or Antigravity OAuth profiles.
- Use Gemini models from a Google AI Pro or Ultra plan through Antigravity.
- Keep one
p2a_key and onemodels.providersentry across your Claude, Codex, Gemini and Kimi plans. - Run the gateway on a remote server where there's no local CLI login by connecting a Claude Pro or Max subscription as an API.
- Connect several accounts of the same provider, so a request that hits a usage limit moves to the next account before any output is sent.
Add Plan2API to openclaw.json
- Sign up with a Google account, connect your Claude, ChatGPT, Google AI or Kimi subscription, and copy your
p2a_key. - Put
PLAN2API_KEYin~/.openclaw/.envor in the gateway's environment, since the config'sapiKeyfield reads${PLAN2API_KEY}and only matches uppercase names. - Add the provider block to
~/.openclaw/openclaw.json(or the file inOPENCLAW_CONFIG_PATH), listing each model you want to use with at least itsid. - Save the file so the config hot-reloads; OpenClaw validates keys strictly, and an unknown key stops the gateway from starting until you run
openclaw doctor --fix.
This example adds the provider block and sets the primary model at the same time.
{
"agents": {
"defaults": {
"model": { "primary": "plan2api/claude/claude-sonnet-5" }
}
},
"models": {
"providers": {
"plan2api": {
"baseUrl": "https://api.plan2api.com/v1",
"apiKey": "${PLAN2API_KEY}",
"api": "openai-completions",
"timeoutSeconds": 300,
"models": [
{
"id": "claude/claude-sonnet-5",
"name": "Claude Sonnet 5 (Plan2API)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1000000
},
{
"id": "openai/gpt-6.1-sol",
"name": "GPT-6.1 Sol (Plan2API)",
"reasoning": true
},
{
"id": "gemini/gemini-3.8-flash-high",
"name": "Gemini 3.8 Flash (Plan2API)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1048576
},
{
"id": "kimi/k3",
"name": "Kimi K3 (Plan2API)",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1048576
}
]
}
}
}
}Pick the default model
OpenClaw model refs follow a provider/model format and split at the first slash. That means plan2api/claude/claude-sonnet-5 tells OpenClaw to use the plan2api provider and send the model id claude/claude-sonnet-5 to the API.
You can set the default in agents.defaults.model.primary, run openclaw models set plan2api/claude/claude-sonnet-5 in your terminal, or pick it in the Control UI (http://127.0.0.1:18789, under Settings, then Models). Run openclaw models list any time to see the available refs. The table below lists the common model refs along with the contextWindow value to set for each one (without contextWindow and with no discovered window, OpenClaw falls back to a 200,000-token budget).
| Model ref | Subscription | contextWindow |
|---|---|---|
| plan2api/ | Claude Pro or Max | 1000000 |
| plan2api/ | Claude Pro or Max | 1000000 |
| plan2api/ | Claude Pro or Max | 200000 |
| plan2api/ | ChatGPT plan (Codex) | From GET / |
| plan2api/ | Google AI Pro or Ultra | 1048576 |
| plan2api/ | Kimi Code membership | 1048576 |
Thinking, images and timeouts
- Setting
reasoning: trueon a model makes OpenClaw sendreasoning_effortwhen thinking is turned on (while/think offomits it), which works across all four providers, thoughxhighandmaxrequirecompat.supportedReasoningEffortson the model entry. - Setting
inputto["text", "image"]lets WebChat and node attachments reach Claude, Gemini and Kimi models as images instead of text-only media references. - Leaving
maxTokensunset tells OpenClaw to send neithermax_tokensnormax_completion_tokens, and Claude models then allow up to 128K output (or 64K onclaude/claude-haiku-4-5). - Setting
timeoutSecondsundermodels.providers.plan2apiextends OpenClaw's default 120-second wait for the first response from a cloud endpoint, which helps on long reasoning turns.
temperature and top_p are ignored on Claude and Codex models and fixed on Kimi (temperature 1, top_p 0.95), so sampling settings only change Gemini output.
Plan2API plans for OpenClaw agents
An OpenClaw agent sends one chat request per model call, so a single task with tool calls and follow-up turns can go through several requests. The Free plan ($0, no card needed) includes 1 connected subscription, 50 chat requests a day resetting at 00:00 UTC, 1 request per second with bursts up to 20, and 4 requests at once, which is plenty for testing your config.
For daily agent runs, Pro is $12 a month or $99 a year with no daily request cap, 10 requests per second with bursts up to 600, 16 requests at once and 3 connected subscriptions, while Scale is $29 a month or $249 a year with 25 subscriptions and 32 requests at once. Plan2API never bills per token and adds no token quota of its own, so Claude's own usage limits and your other providers' limits still apply alongside the Plan2API plan limits and pricing.
Troubleshooting OpenClaw with Plan2API
- Gateway won't start after editing
~/.openclaw/openclaw.json: OpenClaw stops on unknown or misspelled keys, so runopenclaw doctor --fixto repair the config. 401invalid_api_key:PLAN2API_KEYisn't set in the gateway's process environment or~/.openclaw/.env, so${PLAN2API_KEY}stays unresolved and OpenClaw emits a warning; a revoked or mistyped key gives the same 401.403no_credentials: your vault has no connected subscription for the provider prefix on that model id.400model_not_found: themodels[].identry in your config needs to be the exact model id fromGET /v1/models, such asclaude/claude-sonnet-5without theplan2api/prefix.400unsupported_parameter: the request sent ajson_objectorjson_schemaresponse_formatto a Claude model, which only accepts text responses.429subscription_quota_exhaustedwith aRetry-Afterheader: every connected account for that provider has hit its usage limit until the reset time inRetry-After(or on the Free plan,429daily_requestswhen you pass 50 chat requests before 00:00 UTC).
See the API documentation and error reference for the full list of error codes and streaming error events.
Use the AI subscriptions you already pay for as one OpenAI-compatible API key.
- Free: 1 subscription, 50 requests a day, no card
- Pro: $12 a month
FAQ
How do I add a custom OpenAI-compatible provider to OpenClaw?
Add a provider entry under models.providers in ~/.openclaw/openclaw.json with baseUrl, apiKey, api set to "openai-completions", and a models array listing each model's id. For Plan2API, set baseUrl to https://api.plan2api.com/v1 and apiKey to "${PLAN2API_KEY}".
What model ref do I use for Claude Sonnet 5?
Use plan2api/claude/claude-sonnet-5. OpenClaw splits the ref at the first slash, picks the plan2api provider, and sends the model id claude/claude-sonnet-5 in the request body.
Do I need Plan2API if OpenClaw already signs in to ChatGPT?
Not if you only use Codex, since OpenClaw's built-in ChatGPT OAuth sign-in already handles that. Plan2API is for running Gemini models from a Google AI Pro or Ultra plan, which OpenClaw doesn't sign in to, or putting Claude, Codex, Gemini and Kimi behind one key and one provider block.
Can I use api anthropic-messages with Plan2API?
No, because Plan2API doesn't have an Anthropic /v1/messages endpoint and doesn't accept the x-api-key header. Set api to "openai-completions" for every model, including Claude.
Why does OpenClaw get 401 invalid_api_key from Plan2API?
In most cases ${PLAN2API_KEY} didn't resolve because PLAN2API_KEY isn't defined in the gateway's environment or ~/.openclaw/.env (OpenClaw ignores provider keys in a workspace .env). OpenClaw leaves a missing or empty variable unresolved and emits a warning, and it only substitutes uppercase names. A revoked or mistyped key also returns 401.
Sources
- OpenClaw docs: Custom providersdocs.openclaw.ai
- OpenClaw docs: Model providersdocs.openclaw.ai
- OpenClaw docs: Configurationdocs.openclaw.ai
- OpenClaw docs: Thinking levelsdocs.openclaw.ai
- OpenClaw releases (GitHub)github.com