AI Provider Auth
Set the default model for OpenClaw and verify the assistant can answer before testing Discord replies
AI provider auth must work before Discord replies will work reliably.
Recommended Cue Workspace Flow
If you are setting this up from Cue web, this is the simplest flow:
- In the chat page, click the workspace icon in the top right to open the workspace.
- In the workspace, open the top-right three-dots menu and click Open VS Code.
- In VS Code, create or upload:
~/.openclaw/agents/main/agent/auth-profiles.jsonUse the example auth-profiles.json further below on this page as the starting format.
- Open a terminal in VS Code with `Ctrl+`` or from the top-left menu via Terminal.
- Point OpenClaw at that profile explicitly:
openclaw config set auth.order.openai-codex '["openai-codex:default"]' --json
openclaw config set agents.defaults.model.primary openai-codex/gpt-5.4
openclaw config set agents.defaults.model.fallbacks '[]' --json- Verify the runtime sees the profile:
openclaw models status --jsonThis workflow is useful when you already have a working auth-profiles.json and want to reuse it inside the sandbox without going through interactive login first.
Anthropic API Key
If you want to use Anthropic in the sandbox:
openclaw config set auth.profiles.anthropic:default '{"provider":"anthropic","mode":"api_key"}' --json
openclaw config set auth.order.anthropic '["anthropic:default"]' --json
openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-6"
openclaw config set agents.defaults.model.fallbacks '[]' --jsonThen add the Anthropic key with the auth flow you prefer.
Example ~/.openclaw/agents/main/agent/auth-profiles.json:
{
"version": 1,
"profiles": {
"anthropic:default": {
"type": "api_key",
"provider": "anthropic",
"key": "sk-ant-..."
}
}
}Set the Default Model Explicitly
If you use an API key flow, set the default model explicitly:
openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-6"
openclaw config set agents.defaults.model.fallbacks '[]' --jsonIf you use OpenAI Codex OAuth, set an OpenAI Codex model instead:
openclaw config set agents.defaults.model.primary "openai-codex/gpt-5.3-codex"
openclaw config set agents.defaults.model.fallbacks '[]' --jsonOpenAI Codex OAuth
OpenClaw supports interactive Codex login:
openclaw models auth login --provider openai-codex --set-defaultUse this inside the same sandbox where OpenClaw will run.
Do not assume cached OAuth tokens copied from another tool or machine will refresh cleanly inside a new sandbox. If refresh fails, re-authenticate inside that sandbox.
OpenAI Codex Manual Config
To configure OpenAI Codex via config commands (without interactive login):
openclaw config set auth.profiles.openai-codex:default '{"provider":"openai-codex","mode":"oauth"}' --json
openclaw config set auth.order.openai-codex '["openai-codex:default"]' --json
openclaw config set agents.defaults.model.primary openai-codex/gpt-5.4
openclaw config set agents.defaults.model.fallbacks '[]' --jsonProfile fields (provider and mode) must be set together as a JSON object. Setting them individually will fail validation because the schema requires both fields.
OpenAI Codex in a Sandbox
If you already have a working Codex OAuth profile and want to reuse it in a sandbox, copy the real auth store into:
~/.openclaw/agents/main/agent/auth-profiles.jsonExample:
{
"version": 1,
"profiles": {
"openai-codex:default": {
"type": "oauth",
"provider": "openai-codex",
"access": "<ACCESS_TOKEN>",
"refresh": "<REFRESH_TOKEN>"
}
}
}Then point OpenClaw at that profile explicitly:
openclaw config set auth.order.openai-codex '["openai-codex:default"]' --json
openclaw config set agents.defaults.model.primary openai-codex/gpt-5.4
openclaw config set agents.defaults.model.fallbacks '[]' --jsonThe copied auth-profiles.json already carries the provider and auth type. For a seeded sandbox profile, the required follow-up is selecting it via auth.order and setting the default model.
Verify the runtime sees the profile:
openclaw models status --jsonWhat you want:
defaultModelisopenai-codex/gpt-5.4providersWithOAuthincludesopenai-codexmissingProvidersInUsedoes not includeanthropic
Final Verification
Before testing Discord, verify the assistant itself can answer:
openclaw agent --agent main --message "Reply with OK only"Expected:
OKIf this command fails, fix model auth before continuing.
Common Failure
If you see:
No API key found for provider "anthropic"then the default model is still pointing at Anthropic, or no default model was set at all.