chub-dev 0.1.0 → 0.1.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/bin/chub-mcp +2 -0
- package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
- package/dist/airtable/docs/database/python/DOC.md +1735 -0
- package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
- package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
- package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
- package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
- package/dist/asana/docs/tasks/DOC.md +1396 -0
- package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
- package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
- package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
- package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
- package/dist/auth0/docs/identity/python/DOC.md +1199 -0
- package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
- package/dist/aws/docs/s3/python/DOC.md +1807 -0
- package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
- package/dist/binance/docs/trading/python/DOC.md +1454 -0
- package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
- package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
- package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
- package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
- package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
- package/dist/clerk/docs/auth/python/DOC.md +274 -0
- package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
- package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
- package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
- package/dist/cohere/docs/llm/DOC.md +1335 -0
- package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
- package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
- package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
- package/dist/deepgram/docs/speech/python/DOC.md +685 -0
- package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
- package/dist/deepl/docs/translation/python/DOC.md +944 -0
- package/dist/deepseek/docs/llm/DOC.md +1220 -0
- package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
- package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
- package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
- package/dist/discord/docs/bot/python/DOC.md +1130 -0
- package/dist/elasticsearch/docs/search/DOC.md +1634 -0
- package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
- package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
- package/dist/firebase/docs/auth/DOC.md +1015 -0
- package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
- package/dist/gemini/docs/genai/python/DOC.md +555 -0
- package/dist/github/docs/octokit/DOC.md +1560 -0
- package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
- package/dist/google/docs/bigquery/python/DOC.md +1503 -0
- package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
- package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
- package/dist/huggingface/docs/transformers/DOC.md +948 -0
- package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
- package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
- package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
- package/dist/jira/docs/issues/python/DOC.md +1492 -0
- package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
- package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
- package/dist/landingai-ade/docs/api/DOC.md +620 -0
- package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
- package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
- package/dist/landingai-ade/skills/SKILL.md +489 -0
- package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
- package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
- package/dist/linear/docs/tracker/DOC.md +1554 -0
- package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
- package/dist/livekit/docs/realtime/python/DOC.md +163 -0
- package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
- package/dist/meilisearch/docs/search/DOC.md +1241 -0
- package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
- package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
- package/dist/mongodb/docs/atlas/DOC.md +2041 -0
- package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
- package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
- package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
- package/dist/okta/docs/identity/python/DOC.md +1401 -0
- package/dist/openai/docs/chat/javascript/DOC.md +407 -0
- package/dist/openai/docs/chat/python/DOC.md +568 -0
- package/dist/paypal/docs/checkout/DOC.md +278 -0
- package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
- package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
- package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
- package/dist/plaid/docs/banking/python/DOC.md +1203 -0
- package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
- package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
- package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
- package/dist/prisma/docs/orm/python/DOC.md +1317 -0
- package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
- package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
- package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
- package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
- package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
- package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
- package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
- package/dist/redis/docs/key-value/python/DOC.md +2054 -0
- package/dist/registry.json +2817 -0
- package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
- package/dist/resend/docs/email/DOC.md +1271 -0
- package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
- package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
- package/dist/search-index.json +1 -0
- package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
- package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
- package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
- package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
- package/dist/shopify/docs/storefront/DOC.md +457 -0
- package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
- package/dist/slack/docs/workspace/python/DOC.md +271 -0
- package/dist/square/docs/payments/javascript/DOC.md +1855 -0
- package/dist/square/docs/payments/python/DOC.md +1728 -0
- package/dist/stripe/docs/api/DOC.md +1727 -0
- package/dist/stripe/docs/payments/DOC.md +1726 -0
- package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
- package/dist/stytch/docs/auth/python/DOC.md +1962 -0
- package/dist/supabase/docs/client/DOC.md +1606 -0
- package/dist/twilio/docs/messaging/python/DOC.md +469 -0
- package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
- package/dist/vercel/docs/platform/DOC.md +1940 -0
- package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
- package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
- package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
- package/dist/zendesk/docs/support/python/DOC.md +2297 -0
- package/package.json +22 -6
- package/skills/get-api-docs/SKILL.md +84 -0
- package/src/commands/annotate.js +83 -0
- package/src/commands/build.js +12 -1
- package/src/commands/feedback.js +150 -0
- package/src/commands/get.js +83 -42
- package/src/commands/search.js +7 -0
- package/src/index.js +43 -17
- package/src/lib/analytics.js +90 -0
- package/src/lib/annotations.js +57 -0
- package/src/lib/bm25.js +170 -0
- package/src/lib/cache.js +69 -6
- package/src/lib/config.js +8 -3
- package/src/lib/identity.js +99 -0
- package/src/lib/registry.js +103 -20
- package/src/lib/telemetry.js +86 -0
- package/src/mcp/server.js +177 -0
- package/src/mcp/tools.js +251 -0
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-api
|
|
3
|
+
description: "Claude AI assistant API for text generation, analysis, conversation, streaming, tool use, vision, and batch processing"
|
|
4
|
+
metadata:
|
|
5
|
+
languages: "python"
|
|
6
|
+
versions: "0.84.0"
|
|
7
|
+
updated-on: "2026-03-05"
|
|
8
|
+
source: maintainer
|
|
9
|
+
tags: "anthropic,sdk,llm,ai,claude"
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Anthropic Python SDK Guidelines
|
|
14
|
+
|
|
15
|
+
You are an Anthropic API coding expert. Help me with writing code using the Anthropic API calling the official libraries and SDKs.
|
|
16
|
+
|
|
17
|
+
You can find the official SDK documentation and code samples here:
|
|
18
|
+
https://docs.anthropic.com/claude/reference/
|
|
19
|
+
|
|
20
|
+
## Golden Rule: Use the Correct and Current SDK
|
|
21
|
+
|
|
22
|
+
Always use the Anthropic Python SDK to call Claude models, which is the standard library for all Anthropic API interactions.
|
|
23
|
+
|
|
24
|
+
- **Library Name:** Anthropic Python SDK
|
|
25
|
+
- **Python Package:** `anthropic`
|
|
26
|
+
- **Installation:** `pip install anthropic`
|
|
27
|
+
|
|
28
|
+
**APIs and Usage:**
|
|
29
|
+
|
|
30
|
+
- **Correct:** `from anthropic import Anthropic`
|
|
31
|
+
- **Correct:** `from anthropic import AsyncAnthropic` (for async usage)
|
|
32
|
+
- **Correct:** `client = Anthropic(api_key="...")`
|
|
33
|
+
- **Correct:** `client.messages.create(...)`
|
|
34
|
+
|
|
35
|
+
## Initialization and API Key
|
|
36
|
+
|
|
37
|
+
The `anthropic` library requires creating a client object for all API calls.
|
|
38
|
+
|
|
39
|
+
- Always use `client = Anthropic()` to create a client object.
|
|
40
|
+
- Set `ANTHROPIC_API_KEY` environment variable, which will be picked up automatically.
|
|
41
|
+
- Alternatively, pass the API key directly: `client = Anthropic(api_key="your-key-here")`
|
|
42
|
+
|
|
43
|
+
## Models
|
|
44
|
+
|
|
45
|
+
By default, use the following models as of March 2026:
|
|
46
|
+
|
|
47
|
+
- **General Tasks:** `claude-sonnet-4-6-20250827`
|
|
48
|
+
- **High-performance:** `claude-opus-4-6-20250826`
|
|
49
|
+
- **Fast and Efficient:** `claude-haiku-4-5-20251001`
|
|
50
|
+
|
|
51
|
+
Previous generation models (still supported):
|
|
52
|
+
- `claude-sonnet-4-20250514`, `claude-opus-4-20250514`
|
|
53
|
+
- `claude-3-5-haiku-20241022`
|
|
54
|
+
|
|
55
|
+
Do not use deprecated models: `claude-3-7-sonnet`, `claude-3-5-sonnet`, `claude-3-opus`
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
# List all available models
|
|
59
|
+
models = client.models.list()
|
|
60
|
+
```
|
|
61
|
+
```python
|
|
62
|
+
# List all deprecated models
|
|
63
|
+
from anthropic.resources.messages.messages import DEPRECATED_MODELS
|
|
64
|
+
for model, deprecation_date in DEPRECATED_MODELS.items():
|
|
65
|
+
print(f"{model}: deprecated {deprecation_date}")
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- It is acceptable to use specific dated versions if consistency is required.
|
|
69
|
+
- Avoid using deprecated models - check the SDK documentation for deprecation notices.
|
|
70
|
+
|
|
71
|
+
## Basic Inference (Text Generation)
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from anthropic import Anthropic
|
|
75
|
+
|
|
76
|
+
client = Anthropic()
|
|
77
|
+
|
|
78
|
+
message = client.messages.create(
|
|
79
|
+
model="claude-sonnet-4-20250514",
|
|
80
|
+
max_tokens=1024,
|
|
81
|
+
messages=[
|
|
82
|
+
{
|
|
83
|
+
"role": "user",
|
|
84
|
+
"content": "Hello, Claude"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
print(message.content)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Multimodal Inputs
|
|
92
|
+
|
|
93
|
+
### Image Inputs
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
message = client.messages.create(
|
|
97
|
+
model="claude-sonnet-4-20250514",
|
|
98
|
+
max_tokens=1024,
|
|
99
|
+
messages=[
|
|
100
|
+
{
|
|
101
|
+
"role": "user",
|
|
102
|
+
"content": [
|
|
103
|
+
{
|
|
104
|
+
"type": "image",
|
|
105
|
+
"source": {
|
|
106
|
+
"type": "base64",
|
|
107
|
+
"media_type": "image/jpeg",
|
|
108
|
+
"data": "/9j/4AAQSkZJRgABAQ..."
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"type": "text",
|
|
113
|
+
"text": "What's in this image?"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### File Uploads
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from pathlib import Path
|
|
125
|
+
|
|
126
|
+
client.beta.files.upload(
|
|
127
|
+
file=Path("/path/to/file"),
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Async Usage
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
import asyncio
|
|
135
|
+
from anthropic import AsyncAnthropic
|
|
136
|
+
|
|
137
|
+
client = AsyncAnthropic()
|
|
138
|
+
|
|
139
|
+
async def main():
|
|
140
|
+
message = await client.messages.create(
|
|
141
|
+
model="claude-sonnet-4-20250514",
|
|
142
|
+
max_tokens=1024,
|
|
143
|
+
messages=[
|
|
144
|
+
{
|
|
145
|
+
"role": "user",
|
|
146
|
+
"content": "Hello, Claude"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
)
|
|
150
|
+
print(message.content)
|
|
151
|
+
|
|
152
|
+
asyncio.run(main())
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Advanced Capabilities and Configurations
|
|
156
|
+
|
|
157
|
+
### System Instructions
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
message = client.messages.create(
|
|
161
|
+
model="claude-sonnet-4-20250514",
|
|
162
|
+
max_tokens=1024,
|
|
163
|
+
system="You are a helpful assistant that speaks like a pirate.",
|
|
164
|
+
messages=[
|
|
165
|
+
{
|
|
166
|
+
"role": "user",
|
|
167
|
+
"content": "Hello!"
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Thinking
|
|
174
|
+
|
|
175
|
+
Configure Claude's extended thinking (reasoning process):
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
message = client.messages.create(
|
|
179
|
+
model="claude-sonnet-4-6-20250827",
|
|
180
|
+
max_tokens=16000,
|
|
181
|
+
messages=[
|
|
182
|
+
{
|
|
183
|
+
"role": "user",
|
|
184
|
+
"content": "Solve this complex problem step by step."
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
thinking={
|
|
188
|
+
"type": "enabled",
|
|
189
|
+
"budget_tokens": 10000
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Tool Use (Function Calling)
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
def get_weather(location: str) -> str:
|
|
198
|
+
return f"Weather in {location}: 72°F and sunny"
|
|
199
|
+
|
|
200
|
+
message = client.messages.create(
|
|
201
|
+
model="claude-sonnet-4-20250514",
|
|
202
|
+
max_tokens=1024,
|
|
203
|
+
messages=[
|
|
204
|
+
{
|
|
205
|
+
"role": "user",
|
|
206
|
+
"content": "What's the weather in San Francisco?"
|
|
207
|
+
}
|
|
208
|
+
],
|
|
209
|
+
tools=[
|
|
210
|
+
{
|
|
211
|
+
"type": "custom",
|
|
212
|
+
"name": "get_weather",
|
|
213
|
+
"description": "Get current weather for a location",
|
|
214
|
+
"input_schema": {
|
|
215
|
+
"type": "object",
|
|
216
|
+
"properties": {
|
|
217
|
+
"location": {
|
|
218
|
+
"type": "string",
|
|
219
|
+
"description": "The city and state, e.g. San Francisco, CA"
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"required": ["location"]
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
]
|
|
226
|
+
)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Streaming Responses
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
stream = client.messages.create(
|
|
233
|
+
model="claude-sonnet-4-20250514",
|
|
234
|
+
max_tokens=1024,
|
|
235
|
+
messages=[
|
|
236
|
+
{
|
|
237
|
+
"role": "user",
|
|
238
|
+
"content": "Tell me a story"
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
stream=True
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
for event in stream:
|
|
245
|
+
if event.type == "content_block_delta":
|
|
246
|
+
print(event.delta.text, end="", flush=True)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Streaming Helpers
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
async with client.messages.stream(
|
|
253
|
+
model="claude-sonnet-4-20250514",
|
|
254
|
+
max_tokens=1024,
|
|
255
|
+
messages=[
|
|
256
|
+
{
|
|
257
|
+
"role": "user",
|
|
258
|
+
"content": "Say hello there!"
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
) as stream:
|
|
262
|
+
async for text in stream.text_stream:
|
|
263
|
+
print(text, end="", flush=True)
|
|
264
|
+
print()
|
|
265
|
+
|
|
266
|
+
message = await stream.get_final_message()
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Token Counting
|
|
270
|
+
|
|
271
|
+
```python
|
|
272
|
+
count = client.messages.count_tokens(
|
|
273
|
+
model="claude-sonnet-4-20250514",
|
|
274
|
+
messages=[
|
|
275
|
+
{"role": "user", "content": "Hello, world"}
|
|
276
|
+
]
|
|
277
|
+
)
|
|
278
|
+
print(f"Input tokens: {count.input_tokens}")
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Message Batches
|
|
282
|
+
|
|
283
|
+
```python
|
|
284
|
+
batch = await client.messages.batches.create(
|
|
285
|
+
requests=[
|
|
286
|
+
{
|
|
287
|
+
"custom_id": "request-1",
|
|
288
|
+
"params": {
|
|
289
|
+
"model": "claude-sonnet-4-20250514",
|
|
290
|
+
"max_tokens": 1024,
|
|
291
|
+
"messages": [{"role": "user", "content": "Hello"}]
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Specialized Deployments
|
|
299
|
+
|
|
300
|
+
### AWS Bedrock
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from anthropic import AnthropicBedrock
|
|
304
|
+
|
|
305
|
+
client = AnthropicBedrock(
|
|
306
|
+
aws_region="us-east-1",
|
|
307
|
+
aws_profile="default"
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
message = client.messages.create(
|
|
311
|
+
model="anthropic.claude-sonnet-4-20250514-v1:0",
|
|
312
|
+
max_tokens=1024,
|
|
313
|
+
messages=[
|
|
314
|
+
{
|
|
315
|
+
"role": "user",
|
|
316
|
+
"content": "Hello!"
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Google Vertex AI
|
|
323
|
+
|
|
324
|
+
```python
|
|
325
|
+
from anthropic import AnthropicVertex
|
|
326
|
+
|
|
327
|
+
client = AnthropicVertex()
|
|
328
|
+
|
|
329
|
+
message = client.messages.create(
|
|
330
|
+
model="claude-sonnet-4@20250514",
|
|
331
|
+
max_tokens=1024,
|
|
332
|
+
messages=[
|
|
333
|
+
{
|
|
334
|
+
"role": "user",
|
|
335
|
+
"content": "Hello!"
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Error Handling
|
|
342
|
+
|
|
343
|
+
```python
|
|
344
|
+
import anthropic
|
|
345
|
+
|
|
346
|
+
try:
|
|
347
|
+
message = client.messages.create(
|
|
348
|
+
model="claude-sonnet-4-20250514",
|
|
349
|
+
max_tokens=1024,
|
|
350
|
+
messages=[
|
|
351
|
+
{
|
|
352
|
+
"role": "user",
|
|
353
|
+
"content": "Hello, Claude"
|
|
354
|
+
}
|
|
355
|
+
]
|
|
356
|
+
)
|
|
357
|
+
except anthropic.APIConnectionError as e:
|
|
358
|
+
print("Connection error occurred")
|
|
359
|
+
except anthropic.RateLimitError as e:
|
|
360
|
+
print("Rate limit exceeded")
|
|
361
|
+
except anthropic.APIStatusError as e:
|
|
362
|
+
print(f"API error: {e.status_code}")
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Configuration Options
|
|
366
|
+
|
|
367
|
+
### Retries
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
client = Anthropic(max_retries=3)
|
|
371
|
+
|
|
372
|
+
client.with_options(max_retries=5).messages.create(...)
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Timeouts
|
|
376
|
+
|
|
377
|
+
```python
|
|
378
|
+
client = Anthropic(timeout=30.0)
|
|
379
|
+
|
|
380
|
+
client.with_options(timeout=60.0).messages.create(...)
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## Useful Links
|
|
384
|
+
|
|
385
|
+
- **Documentation:** https://docs.anthropic.com/claude/reference/
|
|
386
|
+
- **API Keys:** https://console.anthropic.com/
|
|
387
|
+
- **SDK Repository:** https://github.com/anthropics/anthropic-sdk-python
|
|
388
|
+
- **Rate Limits:** https://docs.anthropic.com/claude/reference/rate-limits
|
|
389
|
+
- **Error Codes:** https://docs.anthropic.com/claude/reference/errors
|