Bryan Anthonio

Fix Claude Code Credential Errors for Pro Users by Switching to Sonnet

Configure Claude Code to use the Sonnet model instead of Opus to fix Pro user API authentication in CLI and GitHub workflows.

Comments

I recently encountered this error when using Claude Code and my Claude Code GitHub Actions:

API Error: 400
This credential is only authorized for use with Claude Code
and cannot be used for other API requests.

This was puzzling given that I had followed the official setup instructions to get started. After some investigation, I discovered this affects Pro-tier users specifically.

What’s the root cause? Claude Code’s default configuration uses the Opus model, which Pro-tier users don’t have access to. You can upgrade to the Max-tier if you’d like to use the Opus model. However, a workaround solution is to configure Claude Code to use the Sonnet model instead.

Contents

Fixing the CLI Configuration

The quickest fix is to use the /model command in Claude Code to select Sonnet as your model:

> /model
╭────────────────────────────────────────────────────────────────────────╮
│                                                                        │
│  Select model                                                          │
│  Switch between Claude models. Applies to this session and future      │
│  Claude Code sessions. For custom model names, specify with --model.   │
│                                                                        │
│     1. Default (recommended)   Opus 4.1 for up to 50% of usage         │
│                                limits, then use Sonnet 4               │
│     2. Opus                    Opus 4.1 for complex tasks · Reaches    │
│                                usage limits faster                     │
│   ❯ 3. Sonnet                  Sonnet 4 for daily use ✔                │
│     4. Opus Plan Mode          Use Opus 4.1 in plan mode, Sonnet 4     │
│                                otherwise                               │
│                                                                        │
╰────────────────────────────────────────────────────────────────────────╯

Select option 3 (Sonnet) to resolve the API credential issue. This setting will persist across future Claude Code sessions.

Fixing GitHub Actions

If you’re using Claude Code in GitHub Actions, you’ll need to update your workflow files to specify the Sonnet model.

Updating claude.yml

In your claude.yml file, add the claude_args parameter with the --model sonnet flag:

# .github/workflows/claude.yml
- name: Run Claude Code
  id: claude
  uses: anthropics/claude-code-action@v1
  with:
    claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
    additional_permissions: |
      actions: read
    claude_args: "--model sonnet"

The key addition is the claude_args: "--model sonnet" line at the bottom of the step configuration.

Updating claude-code-review.yml

For the code review workflow update the existing claude_args parameter to include the model specification:

# github/workflows/claude-code-review.yml
claude_args: '--model sonnet --allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'

Simply add --model sonnet at the beginning of the existing claude_args string.

Comments

Back to top