Using OpenClaw with NanoGPT

NanoGPT works with OpenClaw as an OpenAI-compatible model provider. This gives your OpenClaw agents pay-per-use access to NanoGPT models through the standard Chat Completions API.
For additional NanoGPT tools such as web search, scraping, image generation, audio, and data enrichment, you can also register the NanoGPT MCP server.
Before You Start
- Install OpenClaw and complete its initial setup.
- Create or copy your NanoGPT API key from nano-gpt.com/api.
- Make sure your NanoGPT account has enough API balance for the models you plan to use. For subscription-aware routing, see the optional provider plugin below.
1. Store Your NanoGPT API Key
OpenClaw's default global environment file is ~/.openclaw/.env. Add your key there:
NANOGPT_API_KEY=your_nanogpt_api_key
Do not commit this file or paste your key into a shared configuration. OpenClaw also accepts the key from the Gateway process environment.
2. Add NanoGPT as a Model Provider
Open ~/.openclaw/openclaw.json and merge the following provider into your existing configuration:
{
"models": {
"mode": "merge",
"providers": {
"nanogpt": {
"baseUrl": "https://nano-gpt.com/api/v1",
"apiKey": "${NANOGPT_API_KEY}",
"api": "openai-completions",
"models": [
{
"id": "claw-high",
"name": "NanoGPT Claw High"
},
{
"id": "claw-medium",
"name": "NanoGPT Claw Medium"
},
{
"id": "claw-low",
"name": "NanoGPT Claw Low"
}
]
}
}
}
}
The /api/v1 suffix is important: OpenClaw appends /chat/completions when it uses the openai-completions adapter.
The Claw model IDs are stable NanoGPT aliases intended for agent workloads:
claw-highprioritizes capability for difficult, multi-step work.claw-mediumbalances capability and price for everyday agent use.claw-lowprioritizes speed and low cost for routine or high-volume work.
NanoGPT may update the model behind an alias over time. To pin a specific model instead, replace or extend the models array with an ID from the live catalog.
3. Validate and Select a Model
Validate the OpenClaw configuration and confirm that the NanoGPT models appear:
openclaw config validate
openclaw models list --provider nanogpt
Set a default model:
openclaw models set nanogpt/claw-medium
OpenClaw normally reloads configuration changes automatically. If the new provider does not appear, restart the Gateway:
openclaw gateway restart
Get the Current NanoGPT Model Catalog
The three Claw aliases are convenient defaults, but you can use any compatible model in the NanoGPT catalog. Fetch the current list with:
curl -H "Authorization: Bearer $NANOGPT_API_KEY" \
"https://nano-gpt.com/api/v1/models?detailed=true"
When adding a model to OpenClaw, use its NanoGPT model ID in the provider's models array. Select it in OpenClaw as nanogpt/<model-id>.
Optional: Add NanoGPT MCP Tools
Model inference works without MCP. Register the NanoGPT MCP server when an OpenClaw runtime also needs NanoGPT tools for search, scraping, media generation, or enrichment:
{
"mcp": {
"servers": {
"nanogpt": {
"command": "npx",
"args": ["-y", "@nanogpt/mcp"],
"env": {
"NANOGPT_API_KEY": "${NANOGPT_API_KEY}"
}
}
}
}
}
Check that OpenClaw can start the server and discover its tools:
openclaw mcp doctor nanogpt --probe
See the NanoGPT MCP setup page and the machine-readable agent capabilities index for available tools and endpoints.
Optional: Community OpenClaw Provider Plugin
The community-maintained NanoGPT provider plugin for OpenClaw adds automatic model discovery, subscription versus pay-as-you-go routing, NanoGPT-backed web search, image generation, and usage snapshots.
It is an unofficial plugin, so review its installation instructions and source before using it. The direct OpenAI-compatible setup above does not require the plugin.
Troubleshooting
NanoGPT models do not appear
- Confirm the provider
baseUrlis exactlyhttps://nano-gpt.com/api/v1. - Run
openclaw config validateto catch configuration errors. - Run
openclaw models statusto inspect the active provider and authentication state. - Restart the Gateway if the configuration was not hot-reloaded.
Authentication fails
- Confirm
NANOGPT_API_KEYis available to the Gateway process or stored in~/.openclaw/.env. - Do not rely on a project workspace
.envfor provider credentials; use OpenClaw's global environment file. - Test the key against
https://nano-gpt.com/api/v1/modelswith thecurlcommand above.
A model fails or does not support the tools you need
Model capabilities differ. Try one of the Claw aliases or choose another model from the detailed live catalog. Use NanoGPT MCP tools when you need a dedicated search, scraping, or media-generation endpoint rather than model-native tool behavior.
Auto Model shows a 1M limit but selects a smaller model
auto-model is a dynamic routing alias. Its 1M context and output values are discovery ceilings that let OpenClaw configure the alias before NanoGPT knows which concrete model will handle a prompt. The selected model can have smaller limits. NanoGPT automatically clamps OpenClaw's positive max_tokens value to both the selected model's maximum output and the context space left after the prompt. If the prompt itself cannot fit, NanoGPT still returns context_length_exceeded, after which OpenClaw may compact the history or start a fresh session.
OpenClaw can display 0% for a small history against the alias's advertised 1M context because the percentage is rounded. It does not mean the counter is stuck.
A subscriber sees an insufficient-balance error
OpenClaw can make separate requests for the primary model, compaction, utility tasks, and fallback models. Subscription access for auto-model does not make every separately configured model subscription-included. If one of those auxiliary models is pay-as-you-go only and the account has no balance, that request returns a billing error. Choose subscription-included models for those roles or add pay-as-you-go balance.
You can review NanoGPT usage at nano-gpt.com/usage. For additional help, use the support chat on the NanoGPT site or contact the community through our Telegram channel.