Skip to main content
This site is an independent third-party technical service provider. Claude™ and Anthropic® are trademarks of Anthropic, PBC. This site has no affiliation, endorsement, or partnership with Anthropic.

Claude API Base URL Configuration Guide for Cursor, Cline, Dify, Open WebUI, and More

A practical 2026 guide to choosing the right ClaudeAPI base URL for OpenAI-compatible and Anthropic-compatible tools.

ToolsclaudeapicursortutorialEst. read10min
2026.06.27 published
Claude API Base URL Configuration Guide for Cursor, Cline, Dify, Open WebUI, and More

Claude API pricing looks simple at first: input tokens cost one amount, output tokens cost another. In real projects, the bill depends on more than the model table. Context length, output length, prompt caching, model routing, batch jobs, fast modes, search tools, and payment rules all matter.

This guide separates two different pricing contexts:

  • Anthropic’s public Claude Platform pricing
  • ClaudeAPI console pricing and billing rules

ClaudeAPI is an independent third-party technical service provider. Claude and Anthropic are trademarks of their respective owners. This article is based on public information and ClaudeAPI console snapshots; it does not imply that ClaudeAPI is an official Anthropic reseller, agent, partner, or endorsed service.

Prices, model availability, recharge rules, payment channels, and promotional activity can change. Always confirm the final numbers in the Anthropic pricing page and the ClaudeAPI console before making production budget decisions.

The 30-second version

  • Anthropic Claude Platform and ClaudeAPI are separate services with different billing contexts.
  • Anthropic public pricing is useful as a reference, but it is not the same thing as ClaudeAPI account billing.
  • As of the source snapshot, ClaudeAPI console prices for selected models were lower than Anthropic public prices, but this should be described as a console snapshot, not a fixed discount promise.
  • Output tokens are usually several times more expensive than input tokens.
  • Prompt caching can reduce repeated-context cost when cache hits occur.
  • The safest cost strategy is model routing: Haiku for lightweight work, Sonnet for everyday production tasks, and Opus only for high-value hard tasks.

Anthropic public pricing reference

The table below summarizes public Anthropic pricing for selected Claude models. Prices are in USD per million tokens, also called MTok.

Model Input 5-minute cache write Cache read Output
Claude Opus 4.8 $5 $6.25 $0.50 $25
Claude Opus 4.7 $5 $6.25 $0.50 $25
Claude Opus 4.6 $5 $6.25 $0.50 $25
Claude Sonnet 4.6 $3 $3.75 $0.30 $15
Claude Haiku 4.5 $1 $1.25 $0.10 $5

Anthropic released Sonnet 5 on June 30, 2026. Public documentation lists introductory pricing of $2 / MTok input and $10 / MTok output through August 31, 2026, with standard pricing later listed as $3 / MTok input and $15 / MTok output. Whether ClaudeAPI exposes Sonnet 5, and at what price, should be checked in the ClaudeAPI console.

Several pricing details are easy to miss:

  • Prompt cache writes cost more than normal input, while cache reads are much cheaper than normal input.
  • Opus 4.8 Fast Mode is priced at a premium for lower latency.
  • Built-in Web Search is billed separately from token usage.
  • US-only inference can add a pricing multiplier in Anthropic’s public pricing model.
  • Batch processing, where supported, can reduce input and output token cost for asynchronous workloads.

ClaudeAPI console pricing snapshot

ClaudeAPI is a third-party Claude-compatible access platform. Its model list, service capabilities, and billing rules are provided by ClaudeAPI and may change.

The following table is a snapshot from the source article, based on a ClaudeAPI console view dated June 24, 2026. Use it for budget estimation only.

Model ID ClaudeAPI input ClaudeAPI output Cache read Cache write Anthropic public input / output reference Typical use
claude-opus-4-8 $4 $20 $0.40 $5 $5 / $25 Complex reasoning, long context
claude-opus-4-7 $4 $20 $0.40 $5 $5 / $25 Stable Opus-line usage
claude-opus-4-6 $4 $20 $0.40 $5 $5 / $25 Stable Opus-line usage
claude-sonnet-4-6 $2.4 $12 $0.30 $3 $3 / $15 Balanced daily production tasks
claude-haiku-4-5-20251001 $0.8 $4 $0.08 $1 $1 / $5 Lightweight, fast tasks

Again: do not treat this as a permanent price list or a fixed discount relationship. The current account console is the source of truth.

What $1 buys in the snapshot

Using the ClaudeAPI snapshot above:

Model $1 approximate input tokens $1 approximate output tokens Typical chat, 200 input / 500 output
Haiku 4.5 1.25M 250K ~$0.0021
Sonnet 4.6 ~417K ~83K ~$0.0065
Opus 4.8 250K 50K ~$0.0108

For rough Chinese text planning, one Chinese character may be around 1.5 to 2 tokens, depending on content and tokenizer behavior. One million tokens may correspond to roughly 500,000 to 600,000 Chinese characters. Treat this as an estimate, not a billing rule.

Recharge, currency, and payment rules

The recharge page may show USD, CNY, or other options depending on account, region, and payment service. Payment methods, exchange rates, fees, limits, arrival time, refund conditions, and tax rules should be read from the live recharge page.

The source article included this recharge snapshot from June 24, 2026:

Recharge amount Amount paid Snapshot discount Typical use
$10 $10 First test or Claude Code trial
$30 $30 Light development
$50 $50 Several small to medium tasks
$100 $98 -2% Stable Claude Code / Cursor usage
$300 $291 -3% Team or multi-project usage
$500 $475 -5% Higher-volume usage

Promotions need their own rules: organizer, time window, eligible users, calculation method, refund handling, balance validity, and invoice/tax treatment.

Model selection: do not start with Opus for everything

If every request uses Opus, cost rises quickly. A more stable strategy is to route by task complexity.

Classification / extraction / short Q&A / translation / routing
  -> Haiku 4.5

Daily coding / content / document analysis / support / RAG
  -> Sonnet 4.6

Complex refactoring / multi-agent work / long-context deep reasoning
  -> Opus 4.8
Classification / extraction / short Q&A / translation / routing
  -> Haiku 4.5

Daily coding / content / document analysis / support / RAG
  -> Sonnet 4.6

Complex refactoring / multi-agent work / long-context deep reasoning
  -> Opus 4.8

A sample allocation might look like this:

Share Model Use
60-70% Haiku 4.5 Routing, filtering, formatting, lightweight response
20-30% Sonnet 4.6 Main business logic and generation
5-10% Opus 4.8 Planning, critical decisions, difficult fallback

Example using the snapshot prices: if a monthly workload has 10M input tokens and 2M output tokens, using only Sonnet 4.6 costs roughly:

10M input * $2.4 / MTok = $24
2M output * $12 / MTok  = $24
total                   = $48
10M input * $2.4 / MTok = $24
2M output * $12 / MTok  = $24
total                   = $48

With a 70% Haiku / 25% Sonnet / 5% Opus allocation, the same simplified workload is roughly $27.2 in the source estimate. Your real savings depend on task mix, output length, retries, and quality requirements.

Cost optimization method 1: prompt caching

Prompt caching helps when your requests reuse a large stable prefix, such as:

  • system prompts
  • policy documents
  • long few-shot examples
  • RAG context
  • agent instructions
  • repeated conversation history

Cache writes cost more than normal input, but cache reads are much cheaper. That means caching only helps when the same prefix is reused enough times.

Example with Anthropic-style SDK:

import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["CLAUDEAPI_KEY"],
    base_url="https://gw.claudeapi.com",
)

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    system=[
        {
            "type": "text",
            "text": "You are a legal assistant. Use the following policy library...\n\n" + large_policy_context,
            "cache_control": {"type": "ephemeral"},
        }
    ],
    messages=[
        {
            "role": "user",
            "content": "Is this penalty clause enforceable?",
        }
    ],
)

print(response.usage)
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["CLAUDEAPI_KEY"],
    base_url="https://gw.claudeapi.com",
)

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    system=[
        {
            "type": "text",
            "text": "You are a legal assistant. Use the following policy library...\n\n" + large_policy_context,
            "cache_control": {"type": "ephemeral"},
        }
    ],
    messages=[
        {
            "role": "user",
            "content": "Is this penalty clause enforceable?",
        }
    ],
)

print(response.usage)

Track cache writes and cache reads separately. The hit rate determines whether caching is actually saving money.

Cost optimization method 2: control output length

Output tokens usually cost several times more than input tokens. The easiest way to waste money is to let the model write much more than the task requires.

Use constraints like:

  • “Return JSON only.”
  • “Do not explain.”
  • “Use at most 8 bullets.”
  • “Keep the answer under 120 words.”
  • “Return only {category, confidence}.”

Example:

response = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=200,
    system="Return JSON only with fields: {category, confidence}. Do not add explanation.",
    messages=[
        {
            "role": "user",
            "content": "User feedback: this button does nothing when clicked.",
        }
    ],
)
response = client.messages.create(
    model="claude-haiku-4-5-20251001",
    max_tokens=200,
    system="Return JSON only with fields: {category, confidence}. Do not add explanation.",
    messages=[
        {
            "role": "user",
            "content": "User feedback: this button does nothing when clicked.",
        }
    ],
)

Also trim long chat history. Keep recent turns and a compact summary instead of sending the entire conversation forever.

Cost optimization method 3: route by task

Model routing is the most reliable cost-control pattern.

High-frequency low-value tasks should not use the most expensive model by default. Use Haiku for lightweight preprocessing, Sonnet for normal production quality, and Opus only when the task needs it.

In practice:

  • use Haiku for classification and formatting
  • use Sonnet for normal coding and content
  • use Opus for complex plans, difficult reasoning, and high-value review

Integration basics

ClaudeAPI supports Anthropic-style and OpenAI-compatible access patterns.

For Anthropic SDK style clients, use:

https://gw.claudeapi.com
https://gw.claudeapi.com

For OpenAI-compatible clients, use:

https://gw.claudeapi.com/v1
https://gw.claudeapi.com/v1

Python with anthropic SDK

import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["CLAUDEAPI_KEY"],
    base_url="https://gw.claudeapi.com",
)

response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.content[0].text)
import os
import anthropic

client = anthropic.Anthropic(
    api_key=os.environ["CLAUDEAPI_KEY"],
    base_url="https://gw.claudeapi.com",
)

response = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.content[0].text)

Node.js / TypeScript

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.CLAUDEAPI_KEY!,
  baseURL: "https://gw.claudeapi.com",
});

const response = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

console.log(response.content[0]);
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.CLAUDEAPI_KEY!,
  baseURL: "https://gw.claudeapi.com",
});

const response = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});

console.log(response.content[0]);

cURL with OpenAI-compatible path

curl https://gw.claudeapi.com/v1/chat/completions \
  -H "Authorization: Bearer $CLAUDEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
curl https://gw.claudeapi.com/v1/chat/completions \
  -H "Authorization: Bearer $CLAUDEAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Use environment variables or a secret manager. Do not hard-code real API keys in source code.

FAQ

Are prices billed in USD or CNY?

Model pricing is usually shown in USD per million tokens. Recharge and settlement currency may include USD or CNY depending on the account and payment page. Use the live recharge page and console for final rules.

Opus 4.8, 4.7, and 4.6 have the same public input/output price. Which should I use?

Opus 4.8 is the newer Opus version. Choose based on actual task evaluation, compatibility, and migration cost. If you have already tuned production prompts on an older model, test before switching.

How much can prompt caching save?

Cache reads are much cheaper than normal input tokens, but cache writes cost extra. Savings depend on repeated context, hit rate, TTL, and request mix. Measure with real usage data.

Should I use Fast Mode?

Fast Mode is useful when latency matters enough to justify the premium, such as interactive IDE experiences. For offline or non-real-time work, standard mode is usually the better default.

Why does Claude Code use more tokens than a normal chat?

Claude Code may read project files, include tool results, inspect logs, and carry task context across multiple steps. A single coding task can use much more context than a normal chat message.

Is ClaudeAPI an official Anthropic service?

No. ClaudeAPI is an independent third-party technical service provider. Claude and Anthropic are trademarks of their respective owners.

Final advice

Use pricing tables as a planning tool, not as the whole cost model.

If you remember one thing, remember this: model choice should follow real task value. Use Haiku or Sonnet for lightweight and normal work, reserve Opus for tasks that truly require it, and enable prompt caching only when repeated context makes it worthwhile.

Before scaling up:

  • run real sample workloads
  • record input and output tokens
  • monitor retries and cache hit rate
  • set budget alerts
  • keep model routing explicit

That is how you turn Claude API pricing from a surprise into an engineering variable.

Sources

Related Articles