Claude API Integration Guide: How to Connect Claude to Your Business
by Sandlabs Team, Founder, Sandlabs
Claude API searches have grown 17x in six months. Businesses are moving beyond chatbots and into production AI — integrating Claude directly into their products, internal tools, and workflows.
This guide covers the practical side of Claude API integration: how it works, common integration patterns, production considerations, and when to build in-house vs. hire a specialist.
Claude API Basics
The Claude API lets you programmatically access Claude's capabilities — text generation, analysis, document processing, code writing, and tool use — from any application.
Authentication
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6-20260320",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Summarise this quarterly report..."}
]
}'
You get an API key from console.anthropic.com. Pricing is per-token (input and output separately), with volume discounts available.
Available Models
| Model | Best For | Speed | Cost |
|---|---|---|---|
| Claude Opus 4.6 | Complex reasoning, multi-step tasks, coding | Slower | Highest |
| Claude Sonnet 4.6 | Balance of capability and speed | Fast | Medium |
| Claude Haiku 4.5 | Simple tasks, high throughput, cost-sensitive | Fastest | Lowest |
Our recommendation: Start with Sonnet for most business applications. Use Opus for complex reasoning (multi-agent systems, financial analysis). Use Haiku for high-volume, simple tasks (classification, extraction).
Official SDKs
Python:
from anthropic import Anthropic
client = Anthropic() # Uses ANTHROPIC_API_KEY env var
message = client.messages.create(
model="claude-sonnet-4-6-20260320",
max_tokens=1024,
messages=[
{"role": "user", "content": "Analyse this financial statement..."}
]
)
print(message.content[0].text)
TypeScript/Node.js:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const message = await client.messages.create({
model: "claude-sonnet-4-6-20260320",
max_tokens: 1024,
messages: [
{ role: "user", content: "Analyse this financial statement..." }
],
});
console.log(message.content[0].text);
Common Integration Patterns
Pattern 1: Document Processing Pipeline
Extract structured data from unstructured documents — invoices, contracts, financial statements, compliance forms.
from anthropic import Anthropic
import json
client = Anthropic()
def process_invoice(document_text: str) -> dict:
message = client.messages.create(
model="claude-sonnet-4-6-20260320",
max_tokens=1024,
messages=[{
"role": "user",
"content": f"""Extract the following fields from this invoice as JSON:
- invoice_number
- date
- vendor_name
- line_items (array of: description, quantity, unit_price, total)
- subtotal
- tax
- total
Invoice text:
{document_text}"""
}]
)
return json.loads(message.content[0].text)
Real-world example: We built a document processing pipeline for a mortgage broker that extracts commission data from lender remittance files — processing files from 24+ aggregators with different formats. Claude handles the format variation that would require dozens of custom parsers otherwise.
Pattern 2: Tool Use (Function Calling)
Let Claude call your functions — query databases, trigger APIs, send notifications.
import anthropic
client = anthropic.Anthropic()
tools = [
{
"name": "lookup_customer",
"description": "Look up a customer by email address",
"input_schema": {
"type": "object",
"properties": {
"email": {
"type": "string",
"description": "Customer email address"
}
},
"required": ["email"]
}
},
{
"name": "create_ticket",
"description": "Create a support ticket for a customer",
"input_schema": {
"type": "object",
"properties": {
"customer_id": {"type": "string"},
"subject": {"type": "string"},
"priority": {"type": "string", "enum": ["low", "medium", "high"]}
},
"required": ["customer_id", "subject", "priority"]
}
}
]
response = client.messages.create(
model="claude-sonnet-4-6-20260320",
max_tokens=1024,
tools=tools,
messages=[{
"role": "user",
"content": "Look up the customer [email protected] and create a high priority ticket about their billing issue."
}]
)
Claude decides which tools to call and in what order. You execute the tool calls and return results. Claude uses the results to continue its work.
Pattern 3: RAG (Retrieval-Augmented Generation)
Connect Claude to your knowledge base so it answers questions with your data, not just its training data.
def answer_with_context(question: str, knowledge_base) -> str:
# 1. Search your knowledge base
relevant_docs = knowledge_base.search(question, top_k=5)
context = "\n\n".join([doc.text for doc in relevant_docs])
# 2. Ask Claude with context
message = client.messages.create(
model="claude-sonnet-4-6-20260320",
max_tokens=2048,
system="You are a helpful assistant. Answer questions based only on the provided context. If the context doesn't contain the answer, say so.",
messages=[{
"role": "user",
"content": f"Context:\n{context}\n\nQuestion: {question}"
}]
)
return message.content[0].text
Pattern 4: Streaming for Real-Time UIs
For chat interfaces and real-time applications, use streaming to show responses as they generate:
with client.messages.stream(
model="claude-sonnet-4-6-20260320",
max_tokens=1024,
messages=[{"role": "user", "content": "Explain our Q1 results..."}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
Pattern 5: Multi-Agent Systems
For complex workflows, use multiple Claude calls with specialised system prompts — each acting as a different "agent."
We built a multi-agent credit assessment system with 7 specialised agents: financial analysis, borrower profiling, collateral assessment, compliance checking, document processing, risk assessment, and report generation. Each agent is a Claude call with a focused system prompt and specific tool access.
Production Considerations
Error handling
The API can return rate limits (429), server errors (500), or overloaded responses (529). Always implement retry with exponential backoff:
from anthropic import Anthropic, RateLimitError, APIError
import time
def call_claude_with_retry(messages, max_retries=3):
client = Anthropic()
for attempt in range(max_retries):
try:
return client.messages.create(
model="claude-sonnet-4-6-20260320",
max_tokens=1024,
messages=messages
)
except RateLimitError:
wait = 2 ** attempt
time.sleep(wait)
except APIError as e:
if attempt == max_retries - 1:
raise
time.sleep(2 ** attempt)
Cost management
- Set max_tokens appropriately — Don't request 4,096 tokens if you only need 256
- Use the right model — Haiku for classification, Sonnet for general tasks, Opus for complex reasoning
- Cache system prompts — Anthropic offers prompt caching that reduces costs for repeated system prompts
- Monitor usage — Track costs per feature/user to identify optimisation opportunities
Security
- Never expose API keys client-side — Always proxy through your backend
- Sanitise inputs — Prevent prompt injection by validating user inputs
- Audit outputs — Log Claude's responses for quality monitoring
- Use system prompts for guardrails — Define boundaries for what Claude should and shouldn't do
Scaling
- Implement queuing — For high-volume applications, queue requests and process asynchronously
- Use batch API — Anthropic offers a batch API for non-real-time processing at 50% reduced cost
- Regional considerations — API endpoints, data residency requirements
Build In-House vs. Hire a Specialist
Build in-house when:
- You have senior engineers with AI/LLM experience
- The integration is straightforward (single API call, simple prompt)
- You need deep, ongoing integration with your codebase
- You have time to iterate and learn
Hire a specialist when:
- You need to move fast (weeks, not months)
- The integration is complex (multi-agent, document processing, tool use)
- You're in a regulated industry needing security controls
- You don't have in-house LLM expertise
- You want a fixed price and guaranteed timeline
What we build at Sandlabs
We've integrated Claude into production systems processing thousands of documents daily. Our typical Claude API integration project:
- Discovery Sprint ($5K-$15K) — Architecture design, prompt engineering, API integration plan
- Build ($15K-$60K) — Production integration with error handling, monitoring, security
- Includes: Prompt versioning, cost monitoring, fallback strategies, documentation
Getting Started
- Get an API key from console.anthropic.com
- Start with the Messages API — the core endpoint for all Claude interactions
- Use the official SDK — Python or TypeScript, both well-maintained
- Begin with Sonnet — best balance of quality, speed, and cost
- Add tool use when you need Claude to interact with your systems
- Consider MCP when you need structured, reusable integrations (read our MCP guide)
For production deployments, read Anthropic's official documentation and consider working with a specialist to avoid common pitfalls.