> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apiyi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Why Do My Logs Show Haiku When Claude Code Is Set to Opus?

> Claude Code hands background helper tasks and some subagents to the lightweight Haiku model to save cost. This is normal client behavior, and you can force everything onto Opus with environment variables.

## Short Answer

**This is Claude Code's own cost-saving mechanism, not the gateway swapping your model.** The `claude-opus-5` you configured in Claude Code only drives the main conversation. Small background tasks such as generating session titles and detecting topics, plus built-in subagents like Explore, run on the cheaper Haiku model by default (for example `claude-haiku-4-5-20251001`), so your logs show both models.

If you want every request to use Opus, force it with environment variables — see [Force Everything onto Opus](#force-everything-onto-opus) below.

## How to Recognize Them in the Logs

In the console's usage logs, these Haiku requests usually have three traits:

* **Same token and group as your Opus requests**: same key, same `ClaudeCode` group, which means they come from the same Claude Code client
* **Very few tokens and a tiny cost per call**: often just tens to a few hundred tokens, in clear contrast to main-conversation Opus requests that run into thousands or tens of thousands
* **They arrive in bursts that follow your actions**: starting a new session, asking Claude Code to search the codebase, or dispatching subtasks

<Info>
  **The model name is exactly what the client sent.** APIYI routes and bills by the `model` field in the request. If you see Haiku in the logs, Claude Code asked for Haiku — those calls are billed at Haiku pricing, never at Opus pricing.
</Info>

## Why Claude Code Does This

Claude Code has a built-in two-tier split between a large and a small model:

| Task type | Default model | Environment variable |
| - | - | - |
| Main conversation, writing code, editing files | Your chosen main model (e.g. Opus) | `ANTHROPIC_MODEL` |
| Session titles, topic detection and other background helpers | Haiku-tier model | `ANTHROPIC_DEFAULT_HAIKU_MODEL` |
| Subagents (e.g. the built-in Explore for codebase search) | Set by each subagent; some default to Haiku | `CLAUDE_CODE_SUBAGENT_MODEL` |

Background tasks and code search don't need much model capability but run often, so Haiku cuts the overall bill noticeably and is faster too. **For most people the default is the right choice.**

## Force Everything onto Opus

If you want every request on Opus (for example, you want higher-quality subagent searches), point every tier at the same Opus model in the `env` block of `~/.claude/settings.json`:

```json theme={null}
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-apiyi-key",
    "ANTHROPIC_BASE_URL": "https://api.apiyi.com",
    "ANTHROPIC_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-opus-5-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-opus-5-5",
    "CLAUDE_CODE_SUBAGENT_MODEL": "claude-opus-5-5"
  }
}
```

**Restart Claude Code** after saving. Your usage logs should then show only `claude-opus-5-5`.

<Tip>
  **Use `claude-opus-5-5` as the main model.** It is newer and works better than `claude-opus-5`, and it is available in the `ClaudeCode` group — just copy the model name from the config above.
</Tip>

<Warning>
  **Running everything on Opus noticeably raises your cost.** Background tasks and subagents fire often, and calls that used to be billed at Haiku pricing will all be billed at Opus pricing. If you only want a smarter small model, a middle ground is to set `ANTHROPIC_DEFAULT_HAIKU_MODEL` to the newer `claude-haiku-5-5` and leave the rest at defaults.
</Warning>

## FAQ

<AccordionGroup>
  <Accordion title="Could the Haiku requests mean my key leaked and someone else is using it?">
    Check the token, IP and timeline. If the Haiku requests use the same token as your Opus requests, come from the same IP and line up with your own activity, they came from your own Claude Code. If you see unfamiliar IPs or heavy usage at times you weren't working, treat it as a key leak — see [Token Management](/en/faq/token-management).
  </Accordion>

  <Accordion title="I switched to Opus with /model. Why is Haiku still there?">
    `/model` only switches the main conversation model. It doesn't change the model used by background helpers and subagents. To change those too, set `ANTHROPIC_DEFAULT_HAIKU_MODEL` and `CLAUDE_CODE_SUBAGENT_MODEL` as shown above.
  </Accordion>

  <Accordion title="How do I change this in tools like CC Switch?">
    Tools like CC Switch also just write Claude Code's environment variables. Set the variables above to `claude-opus-5-5` in the relevant provider profile — see [CC Switch Setup](/en/scenarios/programming/cc-switch).
  </Accordion>
</AccordionGroup>

## Related Docs

<CardGroup cols={2}>
  <Card title="Claude Code Setup Guide" icon="terminal" href="/en/scenarios/programming/claude-code">
    Installation, APIYI configuration and common issues
  </Card>

  <Card title="Codex, ClaudeCode and Default Groups" icon="layers" href="/en/faq/codex-claudecode-default-groups">
    Which token group to use for Claude Code
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.