OpenClaw Setup: API Key, Base URL, and Custom Models
Configure OpenClaw models.providers, a BetterToken API Key, Base URL, OpenAI Responses or Chat Completions models, and validate the Gateway connection.
Connect OpenClaw with your BetterToken API Key, Base URL https://bettertoken.ai/v1, and your chosen Model ID. Copy the exact Model ID from the model plaza.
Key settings
| Field | Value |
|---|---|
| API Key | BetterToken API Key |
| Base URL | https://bettertoken.ai/v1 |
| Model | YOUR_MODEL_ID |
Prerequisites
- Install the latest OpenClaw
- Install Node.js if you use the automatic setup script
- Create a BetterToken API Key
- Copy a Model ID from the model plaza or key Setup dialog
Already have an account? Sign in, top up, then create a key in the console.
Install
macOS / Linux
curl -fsSL https://openclaw.ai/install.sh | bashWindows
iwr -useb https://openclaw.ai/install.ps1 | iexCommand-line setup
The BetterToken Automatic setup script writes the OpenClaw configuration. It requires Node.js. If you do not pass an API Key or Model ID as an argument, the script prompts you for them.
macOS / Linux
curl -fsSL "https://bettertoken.ai/install-openclaw-provider.sh" | bashWindows
iwr "https://bettertoken.ai/install-openclaw-provider.ps1" -OutFile "$env:TEMP\install-openclaw-provider.ps1"; powershell -ExecutionPolicy Bypass -File "$env:TEMP\install-openclaw-provider.ps1"If you omit the model, the script lists the available text models. You can select more than one. The command you copy from the key’s Setup dialog in the workspace already includes the API Key and selected model. To skip the list and specify a model directly:
- macOS / Linux: Replace the final
bashin the command withbash -s -- --model YOUR_MODEL_ID. - Windows: Add
-Model YOUR_MODEL_IDto the end of the command.
What the script changes and how to restore your settings
- Configuration changes. The script runs
openclaw onboard --non-interactivein custom API Key mode for each selected model. It adds BetterToken tomodels.providers, sets the default model to your selection, and runsopenclaw config validate. - API selection. The script uses
openai-responsesfor GPT,anthropic-messagesfor Claude, andopenai-completionsfor other models. - Provider ID. The script uses
bettertokenif all selected models use the same API. When they use different APIs, it usesbettertoken-responses,bettertoken-messages, andbettertoken-chatfor the respective APIs. To verify the connection, use the full model reference the script prints at the end. - Context window. The script sets at least
256000for GPT models and at most128000for other models. To use the same value for all models, setBETTERTOKEN_OPENCLAW_CONTEXT_WINDOWbefore running the script. - Credential storage. The script stores your API Key as plain text in the configuration. To use SecretRef or an environment variable, follow the manual setup below to replace it.
- Backup and restore. Before writing, the script makes a backup in
bettertoken-backups/under the OpenClaw configuration directory. To restore, replaceopenclaw.jsonwith the backup.
Next step. Run the validation and Gateway restart commands in Verify the connection. The script also prints these commands at the end.
Manual setup
Configure OpenClaw
Copy the exact Model ID from the model plaza.
The examples use an API Key placeholder for clarity. For a saved configuration, OpenClaw recommends a SecretRef or environment-variable substitution for models.providers.bettertoken.apiKey; follow the official credential guidance instead of storing a real Key in a shared file.
Responses API
{ "models": { "mode": "merge", "providers": { "bettertoken": { "baseUrl": "https://bettertoken.ai/v1", "apiKey": "YOUR_API_KEY", "api": "openai-responses", "models": [ { "id": "YOUR_MODEL_ID", "name": "YOUR_MODEL_ID" } ] } } }, "agents": { "defaults": { "model": { "primary": "bettertoken/YOUR_MODEL_ID" } } }}Chat Completions
{ "models": { "mode": "merge", "providers": { "bettertoken": { "baseUrl": "https://bettertoken.ai/v1", "apiKey": "YOUR_API_KEY", "api": "openai-completions", "models": [ { "id": "YOUR_MODEL_ID", "name": "YOUR_MODEL_ID" } ] } } }, "agents": { "defaults": { "model": { "primary": "bettertoken/YOUR_MODEL_ID" } } }}For both APIs, set baseUrl to https://bettertoken.ai/v1. OpenClaw appends the path automatically. It calls /v1/responses for openai-responses and /v1/chat/completions for openai-completions.
Verify the connection
Run:
openclaw config validateopenclaw gateway restartopenclaw models listopenclaw models statusThe setup is active when validation passes, the Gateway restarts, and bettertoken/YOUR_MODEL_ID appears in the model list and status. If an existing session still uses an old model, start a new session and check again.
Switch models
Add the new model to models.providers.bettertoken.models, then change agents.defaults.model.primary to bettertoken/YOUR_MODEL_ID. Save, validate, and restart the Gateway.
Common errors
| Error | Fix |
|---|---|
config validate fails | Check JSON commas, quotes, and brackets. |
401 | Copy apiKey again and remove spaces. |
404 | Set baseUrl to https://bettertoken.ai/v1 without adding /responses or /chat/completions. Check that api matches the API you selected. |
| Model missing | Confirm it exists in both the provider model list and agents.defaults.model.primary. |
| Existing session uses the old model | Run openclaw gateway restart and create a new session. |
Advanced setup
Related FAQ
Optional: manage the provider with CC Switch
To manage providers for several tools in one place, see OpenClaw setup in CC Switch.
Technical details
Responses and Chat Completions
For both APIs, set baseUrl to https://bettertoken.ai/v1. OpenClaw appends the path automatically. It calls /v1/responses for openai-responses and /v1/chat/completions for openai-completions.

