How to use Claude with the Anthropic API for document analysis, tool use, and data workflows: Full Guide with models, file upload, and coding capabilities
- Graziano Stefanelli
- 8 hours ago
- 5 min read

Claude can be used programmatically through the Anthropic API to handle documents, code, tools, and structured data.
The Anthropic API transforms Claude from a conversational assistant into a foundation for full-scale, automated knowledge work. By providing robust endpoints for messaging, file handling, tool orchestration, and secure code execution, the API allows organizations to operationalize advanced AI reasoning at every layer of their workflow. Businesses connect Claude to document management systems, CRM, ERP, or cloud storage and use the API to automate analysis, reviews, monitoring, summarization, and much more.
Authentication uses account- or organization-level API keys, generated and rotated via the Anthropic Console.All usage requires strict version headers and opt-in beta flags.
Security is end-to-end: TLS 1.2+, AES-256 at rest, tenant-level isolation, centralized key/quota management.The API now serves use cases in legal, healthcare, fintech, and SaaS where privacy and auditability are essential.
You must choose the right Claude model and token limits depending on the use case.
Anthropic’s Claude lineup includes several models with distinct tradeoffs in capability, speed, and cost. Each call specifies a model name, output cap, and optional system prompt for role control and structure.
System prompts can now enforce rules like “Always cite sources” or “Summarize in Markdown.”
Token management is critical, as prompt + attachments + output must fit the context window.
Table: Claude Model Comparison (2025)
Model | Context Window | Release | Best Use |
Opus 4.2 | 200,000 tokens | Aug 2025 | Complex logic, legal, finance, RAG |
Sonnet 4 beta | 1,000,000 tokens | Beta-3, Aug 2025 | Massive code/data/doc analysis |
Haiku 3.5 | 64,000 tokens | May 2025 | Real-time chat, support, fast jobs |
Choosing the right model ensures efficiency and high answer quality for each workflow.
Claude reads PDFs, DOCX, spreadsheets, and images using the Files API and attachment system.
The Files API is central for document analysis.Upload files (PDF, DOCX, TXT, CSV, Excel, Markdown, images) to /v1/files.
File size: 350 MB per file (tenant/enterprise retention of 0–365 days).Chunking allows Claude to process long documents efficiently, making citations to specific sections or pages possible.
OCR is applied to images and scanned files.
Files are tenant-isolated, timestamped, and logged.
Table: Supported File Types and Limits
File Type | Max Size | Notes |
PDF, DOCX | 350 MB | Full parsing, citations, tables supported |
TXT, Markdown | 350 MB | For code, contracts, or raw text |
CSV, Excel | 350 MB | Data analysis, charting, code execution |
Images (PNG/JPG) | 50 MB | OCR for scanned docs, charts, forms |
Multiple files can be referenced in one request for multi-document cross-analysis.
Claude supports function calling with schema-based tool definitions.
Function calling (tool use) extends Claude beyond text generation, allowing it to trigger external APIs, database routines, or business logic in a safe, auditable manner.
Tool schemas describe the function: names, required/optional parameters, and expected types.
Claude analyzes the prompt and emits a tool_calls array if external action is needed.
Your backend executes the function, returns results to Claude, which integrates them into its answer.
Parallel tool calls and multi-turn reasoning enable workflows like multi-API chaining, real-time lookups, or stepwise automations.
Table: Example Tool Schema
Field | Example Value |
name | "get_stock_price" |
description | "Fetch stock price from API" |
parameters | {"ticker": {"type": "string"}} |
required | ["ticker"] |
Security is maintained through strict input validation, sandboxing, and optional human review for high-risk actions.
Claude can execute Python code in a secure sandbox to analyze data or generate charts.
By enabling the code-execution beta, Claude can ingest uploaded datasets and write, debug, and run Python code using libraries such as pandas, numpy, matplotlib, seaborn, and plotly.
Use cases include:
Financial/medical/statistical reporting
Automated charting
Data QA, cleaning, transformation
Exploratory Data Analysis (EDA)
Sandbox Details:
Limit | Value |
Execution | CPU-only, 60s per code cell |
Libraries | pandas, numpy, matplotlib, etc |
Data Access | Only attached files |
Persistence | Ephemeral VM (no carry-over) |
All code, output, and errors are streamed back in real-time and logged for audit and reproducibility.
Claude supports streaming responses, retries, and long conversation threads.
Claude’s API supports streaming, letting clients receive results as they are generated, enabling responsive interfaces and real-time monitoring.
Streaming events: content_block_delta (partial), message (complete), done (finish)
Error codes:
429 = Rate limit
529 = Overload
608 = Quota exhaustion
522 = Malformed SSE
Retries: Use exponential backoff
Threading: conversation_id persists context, system prompts, file attachments, and tool states across turns, supporting multi-turn, project-length interactions.
Table: Error Codes and Recovery
Code | Meaning | Recommended Action |
429 | Rate limit exceeded | Retry with backoff |
529 | Transient overload | Retry after delay |
608 | Quota exhausted | Wait or upgrade plan |
522 | Malformed SSE/connection | Check stream, reconnect |
SDKs and client libraries simplify integration in Python, JS, Java, and more.
Official SDKs are available for:
Python: Comprehensive, supports streaming, tools, chunking, and error management.
TypeScript/JavaScript: For browser, SaaS, and Node.js apps.
Java: For backend, JVM, and enterprise systems.
Community SDKs for Go and Rust are available, plus well-maintained Postman collections.
Table: SDK/Language Overview
SDK/Language | Best For | Features |
Python | AI portals, data workflows | Full feature, best documentation |
TypeScript/JS | SaaS, dashboards, web agents | Streaming, tools, web integration |
Java | Backend, automation, scale | Robust, thread-safe |
Go, Rust | CLI, fast prototyping | Community-maintained |
Best practice: Always handle streaming events, errors, and retries for resilient deployments.
Enterprise-grade security, data retention, and observability features are included.
Anthropic’s API is built for compliance, privacy, and auditability:
Encryption: TLS 1.2+ in transit, AES-256 at rest
Data retention: Configurable 0–365 days per file/message/conversation
Compliance: SOC 2 Type II, HIPAA (with BAA), GDPR
Tenant isolation: No cross-org file/message visibility
Audit logs: Every file upload, tool call, and code execution is timestamped and exportable
Policy controls allow:
Safety filters (e.g., block political/medical topics)
Manual approval for sensitive actions
Quota/usage dashboards for admins
Table: Security and Compliance Features
Feature | Details |
Encryption | TLS 1.2+, AES-256 |
Retention | 0–365 days, admin-configurable |
Compliance | SOC 2, HIPAA, GDPR |
Isolation | Full tenant separation |
Observability | Exportable logs, real-time monitoring |
Claude’s roadmap includes vector search, external file linking, and AI-native memory.
Claude’s upcoming features will expand enterprise use cases further:
Vector search (/v1/embeddings): Semantic document retrieval, RAG, similarity ranking, knowledge management
Cloud file pointers: Direct links to S3, GCS for bypassing upload bottlenecks
Assistant-initiated uploads: Claude requests data as needed for agent workflows
JSON-only streaming: Eases integration with custom UIs and no-code tools
AI-native memory: Persistent, project-based, multi-session context and recall
Table: Claude Roadmap (2025–2026)
Feature | ETA | Enterprise Impact |
Embeddings API | Q4 2025 | RAG, semantic search, content ranking |
Direct S3/GCS pointer | Q1 2026 | Cloud file ops, multi-GB data ingest |
Assistant file requests | Q2 2026 | Agents, automation, agentic workflows |
JSON streaming | Q4 2025 | Custom pipelines, UI/UX simplification |
Memory thread control | Roadmap 2026 | Persistent agent memory, long projects |
Claude’s API supports robust automation of intelligent workflows, secure tools, and scalable analysis.
With advanced file handling, massive context windows, extensible tool calling, secure code execution, streaming, and strong security/compliance, Claude via the Anthropic API is a forward-looking solution for enterprises and developers building AI into their document-heavy, regulated, and automation-centric workflows.
Key use cases:
Automating legal, compliance, or audit reviews at scale
Building custom finance, insurance, or research agents
Integrating language understanding into documents, emails, chat, or SaaS workflows
Scaling document QA, summarization, and analytics with transparency, audit trails, and policy controls
Claude’s API gives organizations a foundation for secure, extensible, and enterprise-ready LLM-powered automation that’s ready for the evolving needs of 2025 and beyond.
____________
FOLLOW US FOR MORE.
DATA STUDIOS