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.
Files changed (139) hide show
  1. package/README.md +55 -0
  2. package/bin/chub-mcp +2 -0
  3. package/dist/airtable/docs/database/javascript/DOC.md +1437 -0
  4. package/dist/airtable/docs/database/python/DOC.md +1735 -0
  5. package/dist/amplitude/docs/analytics/javascript/DOC.md +1282 -0
  6. package/dist/amplitude/docs/analytics/python/DOC.md +1199 -0
  7. package/dist/anthropic/docs/claude-api/javascript/DOC.md +503 -0
  8. package/dist/anthropic/docs/claude-api/python/DOC.md +389 -0
  9. package/dist/asana/docs/tasks/DOC.md +1396 -0
  10. package/dist/assemblyai/docs/transcription/DOC.md +1043 -0
  11. package/dist/atlassian/docs/confluence/javascript/DOC.md +1347 -0
  12. package/dist/atlassian/docs/confluence/python/DOC.md +1604 -0
  13. package/dist/auth0/docs/identity/javascript/DOC.md +968 -0
  14. package/dist/auth0/docs/identity/python/DOC.md +1199 -0
  15. package/dist/aws/docs/s3/javascript/DOC.md +1773 -0
  16. package/dist/aws/docs/s3/python/DOC.md +1807 -0
  17. package/dist/binance/docs/trading/javascript/DOC.md +1315 -0
  18. package/dist/binance/docs/trading/python/DOC.md +1454 -0
  19. package/dist/braintree/docs/gateway/javascript/DOC.md +1278 -0
  20. package/dist/braintree/docs/gateway/python/DOC.md +1179 -0
  21. package/dist/chromadb/docs/embeddings-db/javascript/DOC.md +1263 -0
  22. package/dist/chromadb/docs/embeddings-db/python/DOC.md +1707 -0
  23. package/dist/clerk/docs/auth/javascript/DOC.md +1220 -0
  24. package/dist/clerk/docs/auth/python/DOC.md +274 -0
  25. package/dist/cloudflare/docs/workers/javascript/DOC.md +918 -0
  26. package/dist/cloudflare/docs/workers/python/DOC.md +994 -0
  27. package/dist/cockroachdb/docs/distributed-db/DOC.md +1500 -0
  28. package/dist/cohere/docs/llm/DOC.md +1335 -0
  29. package/dist/datadog/docs/monitoring/javascript/DOC.md +1740 -0
  30. package/dist/datadog/docs/monitoring/python/DOC.md +1815 -0
  31. package/dist/deepgram/docs/speech/javascript/DOC.md +885 -0
  32. package/dist/deepgram/docs/speech/python/DOC.md +685 -0
  33. package/dist/deepl/docs/translation/javascript/DOC.md +887 -0
  34. package/dist/deepl/docs/translation/python/DOC.md +944 -0
  35. package/dist/deepseek/docs/llm/DOC.md +1220 -0
  36. package/dist/directus/docs/headless-cms/javascript/DOC.md +1128 -0
  37. package/dist/directus/docs/headless-cms/python/DOC.md +1276 -0
  38. package/dist/discord/docs/bot/javascript/DOC.md +1090 -0
  39. package/dist/discord/docs/bot/python/DOC.md +1130 -0
  40. package/dist/elasticsearch/docs/search/DOC.md +1634 -0
  41. package/dist/elevenlabs/docs/text-to-speech/javascript/DOC.md +336 -0
  42. package/dist/elevenlabs/docs/text-to-speech/python/DOC.md +552 -0
  43. package/dist/firebase/docs/auth/DOC.md +1015 -0
  44. package/dist/gemini/docs/genai/javascript/DOC.md +691 -0
  45. package/dist/gemini/docs/genai/python/DOC.md +555 -0
  46. package/dist/github/docs/octokit/DOC.md +1560 -0
  47. package/dist/google/docs/bigquery/javascript/DOC.md +1688 -0
  48. package/dist/google/docs/bigquery/python/DOC.md +1503 -0
  49. package/dist/hubspot/docs/crm/javascript/DOC.md +1805 -0
  50. package/dist/hubspot/docs/crm/python/DOC.md +2033 -0
  51. package/dist/huggingface/docs/transformers/DOC.md +948 -0
  52. package/dist/intercom/docs/messaging/javascript/DOC.md +1844 -0
  53. package/dist/intercom/docs/messaging/python/DOC.md +1797 -0
  54. package/dist/jira/docs/issues/javascript/DOC.md +1420 -0
  55. package/dist/jira/docs/issues/python/DOC.md +1492 -0
  56. package/dist/kafka/docs/streaming/javascript/DOC.md +1671 -0
  57. package/dist/kafka/docs/streaming/python/DOC.md +1464 -0
  58. package/dist/landingai-ade/docs/api/DOC.md +620 -0
  59. package/dist/landingai-ade/docs/sdk/python/DOC.md +489 -0
  60. package/dist/landingai-ade/docs/sdk/typescript/DOC.md +542 -0
  61. package/dist/landingai-ade/skills/SKILL.md +489 -0
  62. package/dist/launchdarkly/docs/feature-flags/javascript/DOC.md +1191 -0
  63. package/dist/launchdarkly/docs/feature-flags/python/DOC.md +1671 -0
  64. package/dist/linear/docs/tracker/DOC.md +1554 -0
  65. package/dist/livekit/docs/realtime/javascript/DOC.md +303 -0
  66. package/dist/livekit/docs/realtime/python/DOC.md +163 -0
  67. package/dist/mailchimp/docs/marketing/DOC.md +1420 -0
  68. package/dist/meilisearch/docs/search/DOC.md +1241 -0
  69. package/dist/microsoft/docs/onedrive/javascript/DOC.md +1421 -0
  70. package/dist/microsoft/docs/onedrive/python/DOC.md +1549 -0
  71. package/dist/mongodb/docs/atlas/DOC.md +2041 -0
  72. package/dist/notion/docs/workspace-api/javascript/DOC.md +1435 -0
  73. package/dist/notion/docs/workspace-api/python/DOC.md +1400 -0
  74. package/dist/okta/docs/identity/javascript/DOC.md +1171 -0
  75. package/dist/okta/docs/identity/python/DOC.md +1401 -0
  76. package/dist/openai/docs/chat/javascript/DOC.md +407 -0
  77. package/dist/openai/docs/chat/python/DOC.md +568 -0
  78. package/dist/paypal/docs/checkout/DOC.md +278 -0
  79. package/dist/pinecone/docs/sdk/javascript/DOC.md +984 -0
  80. package/dist/pinecone/docs/sdk/python/DOC.md +1395 -0
  81. package/dist/plaid/docs/banking/javascript/DOC.md +1163 -0
  82. package/dist/plaid/docs/banking/python/DOC.md +1203 -0
  83. package/dist/playwright-community/skills/login-flows/SKILL.md +108 -0
  84. package/dist/postmark/docs/transactional-email/DOC.md +1168 -0
  85. package/dist/prisma/docs/orm/javascript/DOC.md +1419 -0
  86. package/dist/prisma/docs/orm/python/DOC.md +1317 -0
  87. package/dist/qdrant/docs/vector-search/javascript/DOC.md +1221 -0
  88. package/dist/qdrant/docs/vector-search/python/DOC.md +1653 -0
  89. package/dist/rabbitmq/docs/message-queue/javascript/DOC.md +1193 -0
  90. package/dist/rabbitmq/docs/message-queue/python/DOC.md +1243 -0
  91. package/dist/razorpay/docs/payments/javascript/DOC.md +1219 -0
  92. package/dist/razorpay/docs/payments/python/DOC.md +1330 -0
  93. package/dist/redis/docs/key-value/javascript/DOC.md +1851 -0
  94. package/dist/redis/docs/key-value/python/DOC.md +2054 -0
  95. package/dist/registry.json +2817 -0
  96. package/dist/replicate/docs/model-hosting/DOC.md +1318 -0
  97. package/dist/resend/docs/email/DOC.md +1271 -0
  98. package/dist/salesforce/docs/crm/javascript/DOC.md +1241 -0
  99. package/dist/salesforce/docs/crm/python/DOC.md +1183 -0
  100. package/dist/search-index.json +1 -0
  101. package/dist/sendgrid/docs/email-api/javascript/DOC.md +371 -0
  102. package/dist/sendgrid/docs/email-api/python/DOC.md +656 -0
  103. package/dist/sentry/docs/error-tracking/javascript/DOC.md +1073 -0
  104. package/dist/sentry/docs/error-tracking/python/DOC.md +1309 -0
  105. package/dist/shopify/docs/storefront/DOC.md +457 -0
  106. package/dist/slack/docs/workspace/javascript/DOC.md +933 -0
  107. package/dist/slack/docs/workspace/python/DOC.md +271 -0
  108. package/dist/square/docs/payments/javascript/DOC.md +1855 -0
  109. package/dist/square/docs/payments/python/DOC.md +1728 -0
  110. package/dist/stripe/docs/api/DOC.md +1727 -0
  111. package/dist/stripe/docs/payments/DOC.md +1726 -0
  112. package/dist/stytch/docs/auth/javascript/DOC.md +1813 -0
  113. package/dist/stytch/docs/auth/python/DOC.md +1962 -0
  114. package/dist/supabase/docs/client/DOC.md +1606 -0
  115. package/dist/twilio/docs/messaging/python/DOC.md +469 -0
  116. package/dist/twilio/docs/messaging/typescript/DOC.md +946 -0
  117. package/dist/vercel/docs/platform/DOC.md +1940 -0
  118. package/dist/weaviate/docs/vector-db/javascript/DOC.md +1268 -0
  119. package/dist/weaviate/docs/vector-db/python/DOC.md +1388 -0
  120. package/dist/zendesk/docs/support/javascript/DOC.md +2150 -0
  121. package/dist/zendesk/docs/support/python/DOC.md +2297 -0
  122. package/package.json +22 -6
  123. package/skills/get-api-docs/SKILL.md +84 -0
  124. package/src/commands/annotate.js +83 -0
  125. package/src/commands/build.js +12 -1
  126. package/src/commands/feedback.js +150 -0
  127. package/src/commands/get.js +83 -42
  128. package/src/commands/search.js +7 -0
  129. package/src/index.js +43 -17
  130. package/src/lib/analytics.js +90 -0
  131. package/src/lib/annotations.js +57 -0
  132. package/src/lib/bm25.js +170 -0
  133. package/src/lib/cache.js +69 -6
  134. package/src/lib/config.js +8 -3
  135. package/src/lib/identity.js +99 -0
  136. package/src/lib/registry.js +103 -20
  137. package/src/lib/telemetry.js +86 -0
  138. package/src/mcp/server.js +177 -0
  139. package/src/mcp/tools.js +251 -0
@@ -0,0 +1,503 @@
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: "javascript"
6
+ versions: "0.78.0"
7
+ updated-on: "2026-03-05"
8
+ source: maintainer
9
+ tags: "anthropic,sdk,llm,ai,claude"
10
+ ---
11
+
12
+ # Anthropic JavaScript/TypeScript SDK Coding Guidelines
13
+
14
+ You are an Anthropic API coding expert. Help me with writing code using the Anthropic API calling the official libraries and SDKs.
15
+
16
+ You can find the official SDK documentation and code samples here:
17
+ https://docs.anthropic.com/claude/reference/
18
+
19
+ ## Golden Rule: Use the Correct and Current SDK
20
+
21
+ Always use the Anthropic TypeScript SDK to call the Claude models, which is the standard library for all Anthropic API interactions. Do not use legacy libraries or unofficial SDKs.
22
+
23
+ - **Library Name:** Anthropic TypeScript SDK
24
+ - **NPM Package:** `@anthropic-ai/sdk`
25
+ - **Legacy Libraries**: Other unofficial packages are not recommended
26
+
27
+ **Installation:**
28
+
29
+ - **Correct:** `npm install @anthropic-ai/sdk`
30
+
31
+ **APIs and Usage:**
32
+
33
+ - **Correct:** `import Anthropic from '@anthropic-ai/sdk'`
34
+ - **Correct:** `const client = new Anthropic({})`
35
+ - **Correct:** `await client.messages.create(...)`
36
+ - **Correct:** `await client.messages.stream(...)`
37
+ - **Incorrect:** `AnthropicClient` or `AnthropicAPI`
38
+ - **Incorrect:** `client.generate` or `client.completions`
39
+ - **Incorrect:** Legacy completion endpoints
40
+
41
+ ## Initialization and API key
42
+
43
+ The `@anthropic-ai/sdk` library requires creating an `Anthropic` instance for all API calls.
44
+
45
+ - Always use `const client = new Anthropic({})` to create an instance.
46
+ - Set the `ANTHROPIC_API_KEY` environment variable, which will be picked up automatically.
47
+
48
+ ```javascript
49
+ import Anthropic from '@anthropic-ai/sdk';
50
+
51
+ // Uses the ANTHROPIC_API_KEY environment variable if apiKey not specified
52
+ const client = new Anthropic({});
53
+
54
+ // Or pass the API key directly
55
+ // const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
56
+ ```
57
+
58
+ ## Models
59
+
60
+ - By default, use the following models as of March 2026:
61
+ - **General Tasks:** `claude-sonnet-4-6-20250827`
62
+ - **High-performance:** `claude-opus-4-6-20250826`
63
+ - **Fast and Efficient:** `claude-haiku-4-5-20251001`
64
+
65
+ - Previous generation models (still supported):
66
+ - `claude-sonnet-4-20250514`, `claude-opus-4-20250514`
67
+ - `claude-3-5-haiku-20241022`
68
+
69
+ - Do not use deprecated models: `claude-3-7-sonnet`, `claude-3-5-sonnet`, `claude-3-opus`
70
+
71
+ ## Basic Inference (Text Generation)
72
+
73
+ Here's how to generate a response from a text prompt.
74
+
75
+ ```javascript
76
+ import Anthropic from '@anthropic-ai/sdk';
77
+
78
+ const client = new Anthropic({}); // Assumes ANTHROPIC_API_KEY is set
79
+
80
+ async function run() {
81
+ const message = await client.messages.create({
82
+ max_tokens: 1024,
83
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
84
+ model: 'claude-sonnet-4-20250514',
85
+ });
86
+
87
+ console.log(message.content);
88
+ }
89
+
90
+ run();
91
+ ```
92
+
93
+ Multimodal inputs are supported by passing image data in the messages array. You can include images, documents, and other file types using base64 encoding or file uploads.
94
+
95
+ For file uploads, use the `client.beta.files.upload` method:
96
+
97
+ ```javascript
98
+ import fs from 'fs';
99
+ import Anthropic, { toFile } from '@anthropic-ai/sdk';
100
+
101
+ const client = new Anthropic();
102
+
103
+ // File upload example
104
+ await client.beta.files.upload({
105
+ file: await toFile(fs.createReadStream('/path/to/file'), undefined, { type: 'application/json' }),
106
+ betas: ['files-api-2025-04-14'],
107
+ });
108
+ ```
109
+
110
+ ## Streaming Responses
111
+
112
+ We provide comprehensive support for streaming responses using Server Sent Events (SSE).
113
+
114
+ ### Basic Streaming
115
+
116
+ ```javascript
117
+ import Anthropic from '@anthropic-ai/sdk';
118
+
119
+ const client = new Anthropic();
120
+
121
+ const stream = await client.messages.create({
122
+ max_tokens: 1024,
123
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
124
+ model: 'claude-sonnet-4-20250514',
125
+ stream: true,
126
+ });
127
+
128
+ for await (const messageStreamEvent of stream) {
129
+ console.log(messageStreamEvent.type);
130
+ }
131
+ ```
132
+
133
+ ### Advanced Streaming with Helpers
134
+
135
+ The SDK provides powerful streaming helpers for convenience:
136
+
137
+ ```javascript
138
+ import Anthropic from '@anthropic-ai/sdk';
139
+
140
+ const client = new Anthropic();
141
+
142
+ async function main() {
143
+ const stream = client.messages
144
+ .stream({
145
+ model: 'claude-sonnet-4-20250514',
146
+ max_tokens: 1024,
147
+ messages: [
148
+ {
149
+ role: 'user',
150
+ content: 'Say hello there!',
151
+ },
152
+ ],
153
+ })
154
+ .on('text', (text) => {
155
+ console.log(text);
156
+ });
157
+
158
+ const message = await stream.finalMessage();
159
+ console.log(message);
160
+ }
161
+
162
+ main();
163
+ ```
164
+
165
+ You can cancel streams by calling `stream.controller.abort()` or breaking from loops.
166
+
167
+ ## Tool Use (Function Calling)
168
+
169
+ The SDK supports tool use (function calling) for extending Claude's capabilities.
170
+
171
+ ### Custom Tools
172
+
173
+ Define custom functions that Claude can call:
174
+
175
+ ```javascript
176
+ import Anthropic from '@anthropic-ai/sdk';
177
+
178
+ const client = new Anthropic();
179
+
180
+ async function run() {
181
+ const response = await client.messages.create({
182
+ model: 'claude-sonnet-4-20250514',
183
+ max_tokens: 1024,
184
+ messages: [{ role: 'user', content: "What's the weather like in San Francisco?" }],
185
+ tools: [
186
+ {
187
+ name: 'get_weather',
188
+ description: 'Get the current weather in a given location',
189
+ input_schema: {
190
+ type: 'object',
191
+ properties: {
192
+ location: { description: 'The city and state, e.g. San Francisco, CA', type: 'string' },
193
+ unit: { description: 'Unit for the output - one of (celsius, fahrenheit)', type: 'string' },
194
+ },
195
+ required: ['location'],
196
+ },
197
+ type: 'custom',
198
+ },
199
+ ],
200
+ tool_choice: { type: 'auto' },
201
+ });
202
+
203
+ // Handle tool use in the response
204
+ if (response.content.some((block) => block.type === 'tool_use')) {
205
+ // Process tool calls and provide results back to Claude
206
+ console.log('Claude wants to use a tool!');
207
+ }
208
+ }
209
+
210
+ run();
211
+ ```
212
+
213
+ ### Built-in Beta Tools
214
+
215
+ The beta API provides specialized built-in tools.
216
+
217
+ #### Bash Tool
218
+
219
+ ```javascript
220
+ const response = await client.beta.messages.create({
221
+ model: 'claude-sonnet-4-20250514',
222
+ max_tokens: 1024,
223
+ messages: [{ role: 'user', content: 'List the files in the current directory' }],
224
+ tools: [{ type: 'bash_20250124', name: 'bash' }],
225
+ });
226
+ ```
227
+
228
+ #### Computer Use Tool
229
+
230
+ ```javascript
231
+ const response = await client.beta.messages.create({
232
+ model: 'claude-sonnet-4-20250514',
233
+ max_tokens: 1024,
234
+ messages: [{ role: 'user', content: 'Take a screenshot' }],
235
+ tools: [
236
+ {
237
+ type: 'computer_20250124',
238
+ name: 'computer',
239
+ display_width_px: 1920,
240
+ display_height_px: 1080,
241
+ },
242
+ ],
243
+ });
244
+ ```
245
+
246
+ #### Text Editor Tool
247
+
248
+ ```javascript
249
+ const response = await client.beta.messages.create({
250
+ model: 'claude-sonnet-4-20250514',
251
+ max_tokens: 1024,
252
+ messages: [{ role: 'user', content: 'Create a Python script' }],
253
+ tools: [{ type: 'text_editor_20250124', name: 'str_replace_editor' }],
254
+ });
255
+ ```
256
+
257
+ ### Tool Choice Configuration
258
+
259
+ Control how Claude uses tools:
260
+
261
+ - `{ type: 'auto' }` - Claude decides when to use tools
262
+ - `{ type: 'any' }` - Claude must use a tool
263
+ - `{ type: 'tool', name: 'specific_tool' }` - Force a specific tool
264
+ - `{ disable_parallel_tool_use: true }` - Disable parallel tool execution
265
+
266
+ ## Message Batches
267
+
268
+ The SDK supports the Message Batches API for processing multiple requests efficiently.
269
+
270
+ ### Creating a Batch
271
+
272
+ ```javascript
273
+ await client.messages.batches.create({
274
+ requests: [
275
+ {
276
+ custom_id: 'my-first-request',
277
+ params: {
278
+ model: 'claude-sonnet-4-20250514',
279
+ max_tokens: 1024,
280
+ messages: [{ role: 'user', content: 'Hello, world' }],
281
+ },
282
+ },
283
+ {
284
+ custom_id: 'my-second-request',
285
+ params: {
286
+ model: 'claude-sonnet-4-20250514',
287
+ max_tokens: 1024,
288
+ messages: [{ role: 'user', content: 'Hi again, friend' }],
289
+ },
290
+ },
291
+ ],
292
+ });
293
+ ```
294
+
295
+ ### Getting Batch Results
296
+
297
+ ```javascript
298
+ const results = await client.messages.batches.results(batch_id);
299
+ for await (const entry of results) {
300
+ if (entry.result.type === 'succeeded') {
301
+ console.log(entry.result.message.content);
302
+ }
303
+ }
304
+ ```
305
+
306
+ ## Additional Capabilities
307
+
308
+ ### System Instructions
309
+
310
+ Guide Claude's behavior with system instructions:
311
+
312
+ ```javascript
313
+ const response = await client.messages.create({
314
+ model: 'claude-sonnet-4-20250514',
315
+ max_tokens: 1024,
316
+ messages: [{ role: 'user', content: 'Hello' }],
317
+ system: [{ text: 'You are a helpful assistant that responds in a pirate voice.', type: 'text' }],
318
+ });
319
+ ```
320
+
321
+ ### Thinking
322
+
323
+ Configure Claude's extended thinking (reasoning process):
324
+
325
+ ```javascript
326
+ const response = await client.messages.create({
327
+ model: 'claude-sonnet-4-6-20250827',
328
+ max_tokens: 16000,
329
+ messages: [{ role: 'user', content: 'Solve this complex problem...' }],
330
+ thinking: { type: 'enabled', budget_tokens: 10000 },
331
+ });
332
+ ```
333
+
334
+ ### Temperature and Generation Parameters
335
+
336
+ Control randomness and output:
337
+
338
+ ```javascript
339
+ const response = await client.messages.create({
340
+ model: 'claude-sonnet-4-20250514',
341
+ max_tokens: 1024,
342
+ messages: [{ role: 'user', content: 'Write a creative story' }],
343
+ temperature: 0.7,
344
+ top_k: 5,
345
+ top_p: 0.9,
346
+ });
347
+ ```
348
+
349
+ ### Token Counting
350
+
351
+ Count tokens before making requests:
352
+
353
+ ```javascript
354
+ const tokenCount = await client.messages.countTokens({
355
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
356
+ model: 'claude-sonnet-4-20250514',
357
+ });
358
+ console.log(tokenCount); // { input_tokens: 25, output_tokens: 13 }
359
+ ```
360
+
361
+ ### Auto-pagination
362
+
363
+ Handle paginated responses automatically:
364
+
365
+ ```javascript
366
+ async function fetchAllMessageBatches(params) {
367
+ const allMessageBatches = [];
368
+ // Automatically fetches more pages as needed.
369
+ for await (const messageBatch of client.messages.batches.list({ limit: 20 })) {
370
+ allMessageBatches.push(messageBatch);
371
+ }
372
+ return allMessageBatches;
373
+ }
374
+ ```
375
+
376
+ ## Error Handling
377
+
378
+ The SDK provides comprehensive error handling with specific error types:
379
+
380
+ ```javascript
381
+ import Anthropic from '@anthropic-ai/sdk';
382
+
383
+ const client = new Anthropic();
384
+
385
+ try {
386
+ const message = await client.messages.create({
387
+ max_tokens: 1024,
388
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
389
+ model: 'claude-sonnet-4-20250514',
390
+ });
391
+ } catch (err) {
392
+ if (err instanceof Anthropic.APIError) {
393
+ console.log(err.status); // 400
394
+ console.log(err.name); // BadRequestError
395
+ console.log(err.headers); // {server: 'nginx', ...}
396
+ console.log(err.requestID); // request id string
397
+ } else {
398
+ throw err;
399
+ }
400
+ }
401
+ ```
402
+
403
+ ### Error Types
404
+
405
+ | Status Code | Error Type |
406
+ | ----------- | -------------------------- |
407
+ | 400 | `BadRequestError` |
408
+ | 401 | `AuthenticationError` |
409
+ | 403 | `PermissionDeniedError` |
410
+ | 404 | `NotFoundError` |
411
+ | 422 | `UnprocessableEntityError` |
412
+ | 429 | `RateLimitError` |
413
+ | >=500 | `InternalServerError` |
414
+ | N/A | `APIConnectionError` |
415
+
416
+ All errors extend from `AnthropicError` which extends the standard `Error` class.
417
+
418
+ ### Request IDs
419
+
420
+ All responses include a `_request_id` property for debugging:
421
+
422
+ ```javascript
423
+ const message = await client.messages.create({
424
+ max_tokens: 1024,
425
+ messages: [{ role: 'user', content: 'Hello, Claude' }],
426
+ model: 'claude-sonnet-4-20250514',
427
+ });
428
+ console.log(message._request_id);
429
+ ```
430
+
431
+ ## Advanced Configuration
432
+
433
+ ### Retries
434
+
435
+ Configure automatic retry behavior:
436
+
437
+ ```javascript
438
+ // Configure default retries for all requests
439
+ const client = new Anthropic({
440
+ maxRetries: 3, // default is 2
441
+ });
442
+
443
+ // Or configure per-request
444
+ await client.messages.create(
445
+ { max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-sonnet-4-20250514' },
446
+ { maxRetries: 5 },
447
+ );
448
+ ```
449
+
450
+ ### Timeouts
451
+
452
+ Set custom timeout values:
453
+
454
+ ```javascript
455
+ // Configure default timeout for all requests
456
+ const client = new Anthropic({
457
+ timeout: 20 * 1000, // 20 seconds (default is 10 minutes)
458
+ });
459
+
460
+ // Override per-request
461
+ await client.messages.create(
462
+ { max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-sonnet-4-20250514' },
463
+ { timeout: 5 * 1000 },
464
+ );
465
+ ```
466
+
467
+ ### Logging
468
+
469
+ Enable debug logging:
470
+
471
+ ```javascript
472
+ import Anthropic from '@anthropic-ai/sdk';
473
+
474
+ const client = new Anthropic({
475
+ logLevel: 'debug', // Show all log messages
476
+ });
477
+
478
+ // Or use environment variable
479
+ // ANTHROPIC_LOG=debug
480
+ ```
481
+
482
+ ### Custom Fetch Options
483
+
484
+ Customize the underlying fetch behavior:
485
+
486
+ ```javascript
487
+ import Anthropic from '@anthropic-ai/sdk';
488
+
489
+ const client = new Anthropic({
490
+ fetchOptions: {
491
+ // Custom RequestInit options
492
+ },
493
+ });
494
+ ```
495
+
496
+ ## Useful Links
497
+
498
+ - Documentation: https://docs.anthropic.com/
499
+ - API Reference: https://docs.anthropic.com/claude/reference/
500
+ - Models: https://docs.anthropic.com/claude/docs/models-overview
501
+ - API Pricing: https://www.anthropic.com/pricing
502
+ - Rate Limits: https://docs.anthropic.com/claude/reference/rate-limits
503
+