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
| Project | How it uses Claude |
|---|---|
| LibreChat | Native Anthropic endpoint with model selection and prompt caching |
| LobeChat | Anthropic provider in settings |
| Open WebUI | Through an OpenAI-compatible connection or a pipe function |
| LiteLLM | Routes OpenAI-format requests to Claude and tracks spend |
| CopilotKit | Anthropic adapter for in-app copilots |
Current pricing
As of October 2026, Anthropic lists Claude Opus 5.5 at:
| Item | Price 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
| Use | Monthly tokens | Rough cost on Opus 5.5 |
|---|---|---|
| One heavy user | 3M in, 0.5M out | About $22 |
| Team of 20 on LibreChat | 40M in, 8M out | About $320 |
| Same team with good cache hits | 40M in (70% cached), 8M out | About $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
- Create a workspace in the Claude Console for each app or environment.
- Generate an API key in that workspace and set a monthly spend limit.
- Add the key to the app's server environment, for example
ANTHROPIC_API_KEYin LibreChat's.envfile. - Check your rate-limit tier. New organizations start with lower limits that rise with spend.
- 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
| Job | Sensible choice | Why |
|---|---|---|
| Hard reasoning, code review, long reports | Opus 5.5 | Strongest results, highest price |
| Very long documents or codebases | Fable 5.1 | 1M token context, 128K output |
| Everyday team chat | Sonnet tier | Good quality at lower cost |
| Classification, routing, extraction | Haiku tier | Fast 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.