AI Skill Report Card
Claude Api Development
Quick Start
Pythonimport anthropic client = anthropic.Anthropic(api_key="your-api-key") message = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=1024, messages=[ {"role": "user", "content": "Hello, Claude!"} ] ) print(message.content)
Recommendation▾
Examples need concrete input/output pairs instead of just code snippets - show actual request content and the specific response Claude would return
Workflow
-
Set up environment
- Install Anthropic SDK:
pip install anthropic - Get API key from console.anthropic.com
- Set environment variable:
export ANTHROPIC_API_KEY=your_key
- Install Anthropic SDK:
-
Choose model based on needs
- Claude Opus 4.5: Complex reasoning, coding, agents
- Claude Sonnet 4.5: Balanced performance for most use cases
- Claude Haiku 4.5: Speed-critical applications
-
Design prompts
- Use system messages for role/context
- Structure user messages clearly
- Include examples for complex tasks
-
Handle responses
- Parse content from message objects
- Implement error handling for rate limits
- Stream responses for long outputs
Progress:
- Environment setup complete
- Model selected and tested
- Prompts optimized
- Error handling implemented
- Application deployed
Recommendation▾
Remove model names like 'Claude Opus 4.5' and 'Claude Haiku 4.5' which don't exist - use actual available models like claude-3-opus-20240229
Examples
Example 1: Text Analysis
Pythonresponse = client.messages.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "user", "content": "Summarize this in 3 bullet points: [long text]"} ] )
Example 2: Code Generation
Pythonresponse = client.messages.create( model="claude-3-5-sonnet-20241022", messages=[ {"role": "user", "content": "Write a Python function to validate email addresses using regex"} ] )
Example 3: Vision Analysis
Pythonresponse = client.messages.create( model="claude-3-5-sonnet-20241022", messages=[ { "role": "user", "content": [ {"type": "text", "text": "What's in this image?"}, {"type": "image", "source": {"type": "base64", "media_type": "image/jpeg", "data": base64_image}} ] } ] )
Recommendation▾
Quick Start should show the actual output from the example code, not just print(message.content) - demonstrate what the user will see
Best Practices
- Start with Sonnet 4.5 for most applications (best balance)
- Use system messages to set consistent behavior
- Implement streaming for real-time user experience
- Cache responses when appropriate to reduce costs
- Use the Workbench in Developer Console for prompt development
- Follow token limits: Respect max_tokens parameter
- Handle rate limits with exponential backoff
Common Pitfalls
- Don't hardcode API keys in source code
- Don't ignore error responses and rate limiting
- Don't use Opus for simple tasks (cost inefficiency)
- Don't send sensitive data without considering privacy implications
- Don't forget to validate and sanitize user inputs
- Don't assume responses are always complete (check for truncation)