claude-api

Implements Anthropic Claude API patterns for Python and TypeScript applications.

Updated Mar 25, 2026
One-click install
npx skills add https://github.com/Femad-6/my-skills --skill claude-api-femad-6
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: claude-api
Source: https://github.com/Femad-6/my-skills/tree/main/.github/skills/claude-api
Command: npx skills add https://github.com/Femad-6/my-skills --skill claude-api-femad-6

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires anthropic, @anthropic-ai/sdk.

What problem does it solve? Developers building applications with the Anthropic Claude API often struggle to recall correct SDK syntax, model IDs, and patterns for streaming, tool use, vision, and cost optimization across Python and TypeScript. ## Core Features & Use Cases - SDK Patterns: Ready-to-use code for the Messages API, streaming, system prompts, and error handling in both Python (anthropic) and TypeScript (@anthropic-ai/sdk). - Advanced Capabilities: Covers tool use loops, vision with base64 images, extended thinking, prompt caching, and the Batches API for 50% cost reduction. - Use Case: When building a chatbot that calls external functions, use this Skill to generate the tool definition schema, handle tool_use response blocks, and implement the agentic loop that feeds tool results back to Claude. ## Quick Start Ask the assistant to write a Python script that calls the Claude API with streaming and tool use for a weather lookup function.

Frequently Asked Questions about claude-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the Claude API in Python?

Install the anthropic package with pip, create an Anthropic client that reads ANTHROPIC_API_KEY from the environment, and call client.messages.create with a model ID, max_tokens, and a messages array. The response text is available at message.content[0].text.

How to implement tool use with the Claude API?

Define tools with a name, description, and JSON input_schema, then pass them to messages.create. When the response contains a tool_use block, execute the function with block.input and send the result back in a tool_result message to continue the conversation.

Which Claude model should I use for my application?

Use Sonnet 4 (claude-sonnet-4-0) for most development tasks, Opus 4.1 for complex reasoning and architecture work, and Haiku 3.5 for fast, cost-sensitive, high-volume tasks. For production, prefer pinned snapshot IDs over aliases.

Does the Claude API support streaming responses?

Yes, both SDKs support streaming. In Python use client.messages.stream as a context manager and iterate stream.text_stream; in TypeScript iterate the stream events and handle content_block_delta events with text_delta payloads.

How can I reduce Claude API costs?

Use prompt caching for repeated system prompts (up to 90% savings on cached tokens), the Batches API for non-urgent bulk processing (50% off), Haiku for simple tasks (~75% cheaper than Sonnet), and shorter max_tokens when output length is predictable.

Why am I getting rate limit errors with the Anthropic SDK?

RateLimitError occurs when request volume exceeds your account limits. Catch it specifically, back off (for example sleep 60 seconds), and retry; handle APIConnectionError separately with exponential backoff for network issues.