Claude Opus 4.8 in Claude Code: Setup, the 1M Context Window, and What It Costs
August 2026 update: Claude Opus 5 and Claude Fable 5 are now the current high-end models. See the Claude Opus 5 vs Fable 5 comparison before starting a new integration. This page remains for existing Opus 4.8 configurations.
TL;DR
Claude Opus 4.8 is the strongest model in the current Claude line, and you can drive it from Claude Code today through LLM API. The four models we advertise on GET /v1/models:
| Model ID | Display name | Context (input) | Max output |
|---|---|---|---|
claude-opus-4-8 |
Claude Opus 4.8 | 1,000,000 | 128,000 |
claude-opus-4-7 |
Claude Opus 4.7 | 1,000,000 | 128,000 |
claude-sonnet-4-6 |
Claude Sonnet 4.6 | 1,000,000 | 128,000 |
claude-haiku-4-5-20251001 |
Claude Haiku 4.5 | 200,000 | 64,000 |
Older IDs (claude-opus-4-6, claude-sonnet-4-7, …) are still accepted by /v1/messages and routed to the closest model in the same series — your existing scripts won't break.
The 60-second setup
Claude Code reads two environment variables. Point them at us:
export ANTHROPIC_BASE_URL=https://llmapi.pro
export ANTHROPIC_API_KEY=sk-relay-your-key-here
Then start Claude Code as usual and pick the model:
claude --model claude-opus-4-8
That's it. ANTHROPIC_BASE_URL is a documented, supported way to point Claude Code at a compatible endpoint — you're not patching or hacking the CLI. Get a key from the dashboard; keys look like sk-relay-….
Switching models mid-session
You don't have to restart to change models. Inside Claude Code:
/model claude-sonnet-4-6
A practical split that a lot of our users settle into:
claude-opus-4-8— architecture, hard debugging, anything where one wrong turn costs you an hour. Worth the tokens.claude-sonnet-4-6— the daily driver. Fast, cheap, handles the bulk of edits and reviews.claude-haiku-4-5-20251001— bulk mechanical work, commit-message generation, quick lookups where latency matters more than depth.
A common pattern: keep Sonnet 4.6 as the default and flip to Opus 4.8 with /model only for the gnarly turns. You pay Opus rates only when you actually need Opus.
What the 1M context window actually buys you
Opus 4.8, Opus 4.7, and Sonnet 4.6 all accept up to 1,000,000 input tokens. In Claude Code terms that's roughly an entire mid-sized repository in context at once — you can /add-dir a whole service and ask cross-file questions without the model losing the thread halfway through.
Two things worth knowing:
- Long context is not free. Every turn re-sends the conversation so far, so a 400K-token session costs 400K input tokens per message, not once. If you're deep in a session and the model starts repeating itself,
/compactor start a fresh session — it's cheaper and usually sharper. We wrote up the failure mode in What happens at 400K tokens. - Output is capped at 128K (64K for Haiku). That's the ceiling for a single response — plenty for code, but if you ask for an enormous file in one shot it'll stop at the cap. Ask for it in parts.
Is the 1M context window gone?
Short answer: no. If you searched something like "opus 4.8 1m context gone" because a thread or a client made it look like the window shrank or disappeared, here's the honest picture.
The 1,000,000-token input window is still there and is available on three models through this relay:
| Model ID | Input window | Output cap |
|---|---|---|
claude-opus-4-8 |
1,000,000 | 128,000 |
claude-opus-4-7 |
1,000,000 | 128,000 |
claude-sonnet-4-6 |
1,000,000 | 128,000 |
claude-haiku-4-5-20251001 |
200,000 | 64,000 |
So why do people think it's gone? Usually one of these:
- Confusing the output cap with the input window. The 128,000 number is the output ceiling (how much the model can write back in one response). It is not the size of the context you can send in. Seeing "128K" somewhere and assuming that's the whole window is the most common mix-up.
- A client or plan that doesn't open the window by default. Some front-ends, some direct-vendor entry points, or certain plan tiers cap the effective context below the model's real maximum. The model supports 1M; the path you're using might be handing you less. That's a config/entitlement thing, not the model losing the window.
- A model ID that doesn't actually route to a 1M model. If you typo the ID or fall back to an older one, you can end up on something with a smaller window without realizing it.
How to confirm you actually have the full window
There's no hidden flag — you send a large request and watch whether it's accepted rather than rejected for length. A practical sanity check:
- Confirm your model ID is exactly
claude-opus-4-8(orclaude-opus-4-7/claude-sonnet-4-6). - Feed Claude Code a genuinely large working set (a big file or several files) and keep the session going. If the window were capped low, you'd hit a context-length error early; on these models you won't until you approach 1M input tokens.
- Remember that using the window costs money every turn (see the cost section below) — a full window being available is not the same as it being free.
We won't over-promise: we can't change what a model's architecture supports, and we don't claim a bigger window than Anthropic ships. What we can say plainly is that on claude-opus-4-8 through https://llmapi.pro/v1, the 1,000,000-token input window is live and usable.
Keeping the bill down
The biggest lever isn't the per-token price — it's not burning tokens you didn't need to:
- Default to Sonnet 4.6, escalate to Opus 4.8 deliberately. Most turns don't need the top model.
- Compact long sessions. Context re-sends every turn; a bloated session is a recurring tax.
- Use Haiku for throwaway work. Commit messages, "what does this function do," renaming — Haiku is a fraction of the cost.
There's a longer playbook in Claude Code Cost Optimization: 5 Strategies and a full price breakdown in Claude Code Pricing in 2026.
A cost mental model: why Opus can cost more than you expect
The single most common cost surprise with Opus isn't the per-token rate — it's how context accumulates. If you've ever thought "I only asked one short question, why did that turn cost so much?", this is why.
Every turn re-sends the whole conversation. The API is stateless: each request carries the entire prior context (system prompt, every earlier message, every file you've loaded) plus your new prompt. So the cost of turn N is roughly proportional to the accumulated context at that point, not to the length of the one message you just typed.
A rough mental model:
cost of a session ∝ (average context size) × (number of turns)
Two consequences fall out of this:
- Long sessions get expensive even with short prompts. By turn 30, a one-line question is riding on top of 29 turns of history that get re-sent every time. The prompt is small; the payload isn't.
- Opus amplifies this. Because Opus is the priciest of the four models per token, running a long, context-heavy session on Opus is the worst-case combination. That's exactly why the cost-control advice elsewhere in this post is "default to Sonnet,
/compactoften, send Haiku to do the grunt work, and reserve Opus for the moments that genuinely need it."
This is also why the 1M window is a capability, not a free lunch. Filling that window doesn't just cost once — if you keep the session going, you re-pay for that context on every subsequent turn.
For the deeper version — how to measure context and actively manage it — see Claude Code token cost and context management and Claude Code cost optimization in 2026. For how this maps onto plan choices, Claude Code pricing in 2026 compares Pro vs Max vs metered API.
Verifying it works
Quick smoke test that doesn't spend Claude Code tokens:
curl https://llmapi.pro/v1/messages \
-H "x-api-key: sk-relay-your-key-here" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-4-8",
"max_tokens": 64,
"messages": [{"role": "user", "content": "Reply with the single word: ok"}]
}'
A clean 200 with an ok back means your key, base URL, and model ID are all wired correctly. If you get a 401, the key is wrong; a 404 on the model means a typo in the model ID.
Troubleshooting: "invalid model name", 401, and 404
If you landed here after pasting an error like this into a search box:
api error: 400 ... anthropic_messages: invalid model name passed in
model=claude-opus-4-7. call /v1/models to view available models for your key.
…this section is for you. Here's what each common status code means and how to fix it fast.
400 — invalid model name
A 400 with invalid model name almost always means one of two things:
- The model ID is misspelled, or your key has no channel for it. The string you sent in
model=...doesn't match an ID the relay can route to. Even a small difference (claude-opus-4.8vsclaude-opus-4-8, an extra word, a wrong dash) makes it invalid. - You used an older or retired ID. IDs drift over time. An ID that worked in an old tutorial may no longer be advertised.
The fix: don't hand-type the ID. Ask the API what it advertises. As the error message itself suggests, call GET /v1/models — it's a public endpoint, no key required:
curl https://llmapi.pro/v1/models
That returns the exact IDs the relay advertises. Copy one verbatim into --model or your model field — don't retype it from memory.
For reference, the current precise IDs are:
| Model ID | Use it for |
|---|---|
claude-opus-4-8 |
Hardest reasoning / architecture work |
claude-opus-4-7 |
Previous Opus, still 1M context |
claude-sonnet-4-6 |
Default daily driver, 1M context |
claude-haiku-4-5-20251001 |
Cheap, fast grunt work |
Note that Haiku's ID carries a date suffix (-20251001) while the Opus/Sonnet IDs above do not — copy them character-for-character.
401 — unauthorized
A 401 is an auth problem, not a model problem. Your ANTHROPIC_API_KEY is missing, malformed, or wrong. Check that:
- It starts with
sk-relay-and was copied in full (no trailing space, no line break). - You actually exported it in the shell Claude Code is running in:
echo $ANTHROPIC_API_KEY. - It's a live key from llmapi.pro/register, not a placeholder.
404 — not found
A 404 on a model request is usually a model ID typo that the endpoint treats as "no such model," or a request sent to the wrong path. Re-check:
- The base URL is exactly
https://llmapi.pro/v1(note the:99and the/v1). - The model ID matches one from
GET /v1/models.
In short: 401 = fix your key, 400/404 = fix your model ID, and /v1/models is the source of truth for which IDs are live.
FAQ
Is the 1M context window available on Opus 4.8?
Yes. claude-opus-4-8 supports a 1,000,000-token input window through this relay, as do claude-opus-4-7 and claude-sonnet-4-6. The separate 128,000 figure is the per-response output cap, not the input window — don't confuse the two. (claude-haiku-4-5-20251001 is smaller: 200,000 input / 64,000 output.)
What's the exact model ID for Opus 4.8?
It's claude-opus-4-8 — lowercase, hyphens, no dots, no date suffix. If you're unsure which IDs are live, call GET /v1/models and copy the ID verbatim instead of typing it by hand.
Why am I getting "invalid model name"?
That 400 means the model=... string you sent doesn't match an advertised ID — usually a typo, a wrong format (claude-opus-4.8 instead of claude-opus-4-8), or an old/retired ID. Call GET /v1/models to see the exact IDs and copy one directly. (By contrast, 401 is an auth/key problem, not a model problem.)
How much does Opus 4.8 cost to run? We won't quote a number you'll later find wrong — current rates are on the pricing page. The thing to understand is the shape of the cost: Opus is the most expensive of the four models per token, and because every turn re-sends the full accumulated context, a long Opus session costs far more than the length of any single prompt suggests. Defaulting to Sonnet and reserving Opus for the hard parts is the biggest lever you have.
Can I switch to Sonnet 4.6 without restarting?
Yes. Inside a Claude Code session you can switch models with /model claude-sonnet-4-6 (or to claude-opus-4-8, claude-haiku-4-5-20251001) without quitting or re-exporting anything. A common workflow is Sonnet by default, Opus for a thorny problem, Haiku for cheap bulk edits — all in the same session.
Does setting ANTHROPIC_BASE_URL break Claude Code?
No. ANTHROPIC_BASE_URL is the officially supported way to point Anthropic clients at a compatible endpoint — it's documented, not a hack. Pointing it at https://llmapi.pro/v1 (with a sk-relay-... key) routes Claude Code through this relay while leaving the CLI itself completely standard. To go back to the default, just unset the variable.
llmapi.pro is an independent, Claude-compatible API relay; we are not affiliated with Anthropic. The Claude Code CLI's ANTHROPIC_BASE_URL environment variable is documented and supported by Anthropic for pointing at compatible endpoints.