Skip to main content
Use this guide to connect OpenClaw to CometAPI. Choose one API format and model ID for the first configuration.
OpenClaw v2026.8.1 is also branded OpenClaw 2.0. The package does not use a 2.x version number. See the OpenClaw 2.0 announcement and the v2026.8.1 release notes.
Official OpenClaw references:

Prerequisites

  • Node.js 22.22.3+, 24.15+, or 25.9+. Node 26 is recommended. Node 23 is not supported.
  • A CometAPI account with an active API key from the dashboard.
  • A model ID from the CometAPI Models page.

Installation and upgrades

The official installer can install the CLI without starting onboarding. This keeps model configuration as a separate step.
The following command runs the official installer:
If you manage Node.js and npm yourself, npm 11.16+ and npm 12 accept the --allow-scripts option. The following command installs OpenClaw without starting onboarding:
On npm 11.15 and earlier, omit --allow-scripts=openclaw because that npm version does not recognize the option.Confirm that the installed CLI meets the minimum version for this guide:
Continue to Configure CometAPI. Do not run plain onboarding first, because the guided flow does not expose every custom API adapter.

Configure CometAPI

Use classic onboarding

Classic onboarding is the preferred first-installation path for Chat Completions, Responses, and Anthropic Messages. The following command opens classic onboarding and installs the background service:
In Model/Auth, choose Custom Provider. Then enter the values for one of these compatibility options: Enter the matching provider ID, your-model-id, and your CometAPI API key when prompted. The terminal wizard masks the API key input. The classic Custom Provider menu does not include the Google Generative AI adapter. To use that adapter, complete Configure a provider with config commands, set the primary model, and then run classic onboarding. Choose Keep existing model config when the wizard presents that option.

Configure a provider with config commands

Use this path for the Google adapter or for controlled configuration changes. OpenClaw supports JSON5, so do not parse and rewrite openclaw.json with a strict JSON tool.
OpenClaw’s native config writer validates JSON5 but normalizes the file to JSON when it writes. Existing comments, trailing commas, and formatting may be removed. Create a verified backup before applying a patch if those details are important to you.
First, print the active config path and validate its content:
OpenClaw reads provider API keys from the process environment or the global state .env file. It does not trust a workspace .env file for provider API keys. The global file is ~/.openclaw/.env, or $OPENCLAW_STATE_DIR/.env when OPENCLAW_STATE_DIR is set. If classic onboarding stored the API key, skip the following step. Otherwise, use the tab for your operating system to store the API key without displaying it.
The following commands update COMETAPI_KEY atomically and reject an empty value:
Before you add a provider, inspect its target path. Replace the provider ID in the following command with the ID from your selected tab:
If the command returns a configured provider, stop before applying the example. config patch merges objects, but it replaces arrays. Merge the new model into the provider’s model array before you write that array. This preserves model metadata, custom headers, and other provider settings. Choose one API format. Each patch uses an environment-backed SecretRef, changes only the target config paths, and keeps other config sections intact.
A model ID is not automatically compatible with every API adapter. Select an adapter that the exact CometAPI model and route support, then verify that provider/model/adapter combination with a live request. The your-model-id value below is a configuration placeholder, not a universal compatibility claim.
  • Provider ID: cometapi-openai
  • OpenClaw adapter: openai-completions
  • Base URL: https://api.cometapi.com/v1
  • Primary model reference: cometapi-openai/your-model-id
Create cometapi.patch.json5 with this provider patch:
Validate the patch before OpenClaw writes the config:
If validation succeeds, apply the same patch:
If no primary model is configured, set this model as the default:
Verify the provider configuration and send a minimal model request:
To switch the active OpenClaw chat session, run this chat command:
OpenClaw 2026.8.1 model list with four CometAPI provider formats
For a new provider, openclaw config set provides the same schema and SecretRef checks. Use --strict-json, --merge, and --dry-run before the write. The following alternative previews the Chat Completions provider:
If the dry run succeeds, repeat the command without --dry-run to save it. Do not apply this example to a configured provider. The models array must include the provider’s complete merged model list before a write.

Understand model metadata

The minimal patches declare a text-only model. Add optional metadata only when you have verified the model’s specifications: Incorrect values can hide supported inputs, overstate the usable context, or request an unsupported output size. Keep your-model-id in reusable examples, and use the CometAPI Models page to select a model ID.

Verify the complete setup

After the config or global .env file changes, restart the Gateway:
Then validate the config and Gateway state:
Run the provider-specific commands from the selected API-format tab. A model list or status check confirms configuration only. The openclaw agent exec command sends a real model request. Confirm that it returns OPENCLAW_OK without an unresolved authentication, adapter, or model error. If OpenClaw retries a request, record and inspect every attempt instead of treating the final marker as single-attempt success.

Troubleshooting

Confirm that COMETAPI_KEY is present in the process environment or the global state .env file. Do not print the value into terminal output.After you correct the trusted key source, restart and check the Gateway:
Do not overwrite a provider that has a different baseUrl, api, custom headers, or model metadata. Inspect the target provider first:
Use a different provider ID when both configurations are intentional. If the difference is accidental, create a verified backup before you change the target provider.
Inspect update state before you repair the installation:
These commands preserve the state directory.
Reinstall a known package version while you keep the state directory. First, preview the operation:
If the preview is correct, run the same operation without --dry-run:
Restore a state backup only when the installed code cannot read the state. A state restore can discard sessions and configuration changes that were created after the backup.
Last modified on August 31, 2026