Back to stack index

AI

Anthropic API

Claude models integrated into chat shells and agent kits.

Short answer

The Anthropic API is how programs call Claude models. Open-source chat apps such as LibreChat, LobeChat and Open WebUI, gateways such as LiteLLM, and agent toolkits such as CopilotKit all support it, either through Anthropic's own Messages API or through an OpenAI-compatible layer. The flagship model as of October 2026 is Claude Opus 5.5, released September 22, 2026, priced at $4 per million input tokens and $20 per million output tokens, with cache reads at $0.20 per million. Claude Fable 5.1, from September 1, 2026, offers a 1 million token context window and up to 128,000 output tokens. The same models are also sold through Amazon Bedrock and Google Cloud, which helps companies that already have cloud contracts. Anthropic created the Model Context Protocol, so Claude has first-class support for connecting to external tools, and prompt caching can cut the cost of long, repeated prompts by about 95%.

Flagship model
Claude Opus 5.5, September 22, 2026
Anthropic
Opus 5.5 price
$4 input, $20 output per million tokens
Anthropic pricing
Cache reads
$0.20 per million tokens on Opus 5.5
Anthropic pricing
Long context
Fable 5.1, 1M tokens in, 128K out
Anthropic

Updated October 21, 2026How we evaluate tools

Official site

Directory projects (5)

  • LiteLLM

    OpenAI-compatible proxy that unifies dozens of model providers behind one key.

  • LibreChat

    Multi-model chat UI with plugins, agents, and self-hosted deployment.

  • LobeChat

    Modern chat shell for running and comparing multiple models locally or via API.

  • Open WebUI

    Full-featured web UI for Ollama and OpenAI-compatible backends.

  • CopilotKit

    Embeds copilot-style UI and agent state into existing React products.

The Anthropic API in open-source AI tools: connecting Claude to self-hosted apps in 2026

What the Anthropic API offers

Anthropic's Messages API takes a system prompt and a list of messages and returns Claude's reply, with optional tool use, image and PDF input, extended thinking and streaming. On top of that sit features that matter for self-hosted apps:

  • Prompt caching stores the first part of a prompt, such as a long system prompt, tool definitions or a document, so later calls that reuse it pay the cache-read rate.
  • Message Batches process large jobs asynchronously at a discount.
  • Files and citations let Claude answer from uploaded documents and point to the passages it used.
  • Tool use and MCP connectors let Claude call functions you define or remote MCP servers.

Anthropic also offers an OpenAI-compatible endpoint, so apps that only speak the OpenAI format can reach Claude with a base URL change, though some Claude-specific features such as caching controls are only available through the native API.

Which directory projects use it

ProjectHow it uses Claude
LibreChatNative Anthropic endpoint with model selection and prompt caching
LobeChatAnthropic provider in settings
Open WebUIThrough an OpenAI-compatible connection or a pipe function
LiteLLMRoutes OpenAI-format requests to Claude and tracks spend
CopilotKitAnthropic adapter for in-app copilots

Current pricing

As of October 2026, Anthropic lists Claude Opus 5.5 at:

ItemPrice per million tokens
Input$4.00
Output$20.00
Cache read$0.20

Claude Opus 5 launched on July 24, 2026, at $5 input and $25 output, and Opus 5.5 lowered the price two months later. Claude Fable 5.1, released September 1, 2026, has a 1 million token context window, up to 128,000 output tokens per reply, and cache reads at $0.25 per million. Smaller Haiku and Sonnet models cost less and suit high-volume work such as classification and routing.

Prompt caching in practice

Caching is the biggest lever on Claude costs in self-hosted apps. A document Q&A bot that sends the same 50,000-token handbook with every question pays full input price once, then the cache-read rate on later questions while the cache is warm. On Opus 5.5 that is $0.20 instead of $4 per million tokens. Caches expire after a few minutes of inactivity by default, with a longer option at a higher write price, so caching helps most when questions arrive in bursts. In LibreChat, caching is on by default for supported Claude models. In custom code, mark the reusable block with cache_control.

What a month costs

UseMonthly tokensRough cost on Opus 5.5
One heavy user3M in, 0.5M outAbout $22
Team of 20 on LibreChat40M in, 8M outAbout $320
Same team with good cache hits40M in (70% cached), 8M outAbout $214

Teams that do not need Opus-level reasoning for every message often route routine requests to a smaller Claude model and keep Opus for hard ones. A gateway such as LiteLLM can do this by user, team or model alias.

Claude through Bedrock and Google Cloud

The same Claude models are sold through Amazon Bedrock and Google Cloud's Vertex AI, now part of Gemini Enterprise Agent Platform. AWS listed Claude Opus 5.5 at the same $4 and $20 per million tokens at its standard global cross-region rate in October 2026, with regional rates sometimes higher. On October 18, 2026, Bedrock added structured outputs for Claude. Cloud routes add IAM-based access, private networking and regional data residency, at the cost of more setup. Most open-source apps support Bedrock as a separate provider; LibreChat and LiteLLM both do.

Setting up a key

  1. Create a workspace in the Claude Console for each app or environment.
  2. Generate an API key in that workspace and set a monthly spend limit.
  3. Add the key to the app's server environment, for example ANTHROPIC_API_KEY in LibreChat's .env file.
  4. Check your rate-limit tier. New organizations start with lower limits that rise with spend.
  5. Keep keys out of browser code and repositories.

MCP and tools

Anthropic introduced the Model Context Protocol in November 2024, and Claude has the most mature support for it. Self-hosted apps such as LibreChat and LobeChat can connect MCP servers so Claude can query databases, read files or call internal APIs. Treat each MCP server as code with access to your systems: run trusted servers only and limit what credentials they hold.

Data handling

Anthropic states that it does not train on commercial API data by default. Enterprise customers can arrange zero data retention for eligible endpoints. If data cannot leave your own infrastructure at all, Claude is not an option; use an open model on Ollama or LocalAI instead.

Picking a Claude model for each job

JobSensible choiceWhy
Hard reasoning, code review, long reportsOpus 5.5Strongest results, highest price
Very long documents or codebasesFable 5.11M token context, 128K output
Everyday team chatSonnet tierGood quality at lower cost
Classification, routing, extractionHaiku tierFast and cheap for high volume

In LibreChat you can expose several of these as presets so users choose deliberately, and set the default to a mid-priced model. In LiteLLM you can give each team access only to the models its budget supports.

Extended thinking and rate limits

Claude models can think step by step before answering, and the thinking tokens are billed as output. That improves results on maths, planning and code, but a single answer can use thousands of extra tokens, so turn it on for agents and hard tasks rather than every chat message. Rate limits are set per organization in tokens per minute for input and output separately, and rise with spend. A new organization rolling out Claude to a large team should request a higher tier before launch or route overflow to Bedrock.

Errors to plan for

Claude's API returns a 529 "overloaded" error at busy times, separate from the 429 rate-limit error. Self-hosted apps should retry both with backoff, and a gateway can send the request to Bedrock or another model when retries fail. Set request timeouts generously for long outputs, since a 100,000-token reply can take minutes to stream.

When to use something else

Claude is usually chosen for writing quality, long-document work and coding. If you need image generation, Claude does not produce images. If cost per token is the main concern, open-weight models on Groq are cheaper. Many self-hosted setups offer Claude, GPT and a local model side by side and let each user pick.

Related: OpenAI API stack, MCP stack, Claude alternatives, Claude Code guide, Stack index.

Frequently asked questions

Can I use Claude in LibreChat or Open WebUI?

Yes. LibreChat has a built-in Anthropic endpoint; add ANTHROPIC_API_KEY to its environment file. LobeChat has an Anthropic provider. Open WebUI connects through its OpenAI-style connections, either via Anthropic's OpenAI-compatible endpoint or through a LiteLLM proxy.

How much does the Claude API cost?

Claude Opus 5.5 costs $4 per million input tokens and $20 per million output tokens. Smaller Claude models cost less. Cache reads cost a fraction of normal input, and the Message Batches API offers a discount for jobs that can wait.

Is a Claude Pro subscription the same as API access?

No. Claude Pro and Max are subscriptions for the Claude apps and Claude Code. API usage is billed separately through the Claude Console with prepaid credits or invoicing, and self-hosted apps need an API key from there.

Does Anthropic train on API data?

Anthropic states that it does not train models on data sent through its commercial API by default. Retention periods and zero data retention options are described in its commercial terms and privacy center.

Should I call Anthropic directly or through Bedrock or Vertex?

Call Anthropic directly for the newest features first and the simplest setup. Use Amazon Bedrock or Google Cloud if your company already buys through those clouds, needs data to stay in a specific region, or wants AI spend on the same invoice.

Sources

  1. Anthropic pricing
  2. Claude API docs
  3. Prompt caching
  4. Model Context Protocol