@anthropic-ai/sdk 0.10.2 → 0.12.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 (73) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +51 -86
  3. package/error.d.ts.map +1 -1
  4. package/error.js +2 -1
  5. package/error.js.map +1 -1
  6. package/error.mjs +2 -1
  7. package/error.mjs.map +1 -1
  8. package/index.d.mts +9 -5
  9. package/index.d.ts +9 -5
  10. package/index.d.ts.map +1 -1
  11. package/index.js +7 -5
  12. package/index.js.map +1 -1
  13. package/index.mjs +7 -5
  14. package/index.mjs.map +1 -1
  15. package/lib/MessageStream.d.ts +94 -0
  16. package/lib/MessageStream.d.ts.map +1 -0
  17. package/lib/MessageStream.js +421 -0
  18. package/lib/MessageStream.js.map +1 -0
  19. package/lib/MessageStream.mjs +417 -0
  20. package/lib/MessageStream.mjs.map +1 -0
  21. package/package.json +3 -2
  22. package/resources/beta/beta.d.ts +25 -0
  23. package/resources/beta/beta.d.ts.map +1 -0
  24. package/resources/beta/beta.js +40 -0
  25. package/resources/beta/beta.js.map +1 -0
  26. package/resources/beta/beta.mjs +13 -0
  27. package/resources/beta/beta.mjs.map +1 -0
  28. package/resources/beta/index.d.ts +3 -0
  29. package/resources/beta/index.d.ts.map +1 -0
  30. package/resources/beta/index.js +9 -0
  31. package/resources/beta/index.js.map +1 -0
  32. package/resources/beta/index.mjs +4 -0
  33. package/resources/beta/index.mjs.map +1 -0
  34. package/resources/beta/messages.d.ts +495 -0
  35. package/resources/beta/messages.d.ts.map +1 -0
  36. package/resources/beta/messages.js +29 -0
  37. package/resources/beta/messages.js.map +1 -0
  38. package/resources/beta/messages.mjs +24 -0
  39. package/resources/beta/messages.mjs.map +1 -0
  40. package/resources/completions.d.ts +35 -27
  41. package/resources/completions.d.ts.map +1 -1
  42. package/resources/completions.js.map +1 -1
  43. package/resources/completions.mjs.map +1 -1
  44. package/resources/index.d.ts +1 -0
  45. package/resources/index.d.ts.map +1 -1
  46. package/resources/index.js +3 -1
  47. package/resources/index.js.map +1 -1
  48. package/resources/index.mjs +1 -0
  49. package/resources/index.mjs.map +1 -1
  50. package/src/error.ts +2 -1
  51. package/src/index.ts +11 -5
  52. package/src/lib/MessageStream.ts +515 -0
  53. package/src/resources/beta/beta.ts +28 -0
  54. package/src/resources/beta/index.ts +22 -0
  55. package/src/resources/beta/messages.ts +581 -0
  56. package/src/resources/completions.ts +37 -27
  57. package/src/resources/index.ts +1 -0
  58. package/src/streaming.ts +21 -1
  59. package/src/uploads.ts +2 -3
  60. package/src/version.ts +1 -1
  61. package/streaming.d.ts.map +1 -1
  62. package/streaming.js +15 -0
  63. package/streaming.js.map +1 -1
  64. package/streaming.mjs +15 -0
  65. package/streaming.mjs.map +1 -1
  66. package/uploads.d.ts.map +1 -1
  67. package/uploads.js +2 -1
  68. package/uploads.js.map +1 -1
  69. package/uploads.mjs +2 -1
  70. package/uploads.mjs.map +1 -1
  71. package/version.d.ts +1 -1
  72. package/version.js +1 -1
  73. package/version.mjs +1 -1
@@ -5,23 +5,29 @@ import * as CompletionsAPI from '@anthropic-ai/sdk/resources/completions';
5
5
  import { Stream } from '@anthropic-ai/sdk/streaming';
6
6
  export declare class Completions extends APIResource {
7
7
  /**
8
- * Create a completion
8
+ * Create a Completion
9
9
  */
10
10
  create(body: CompletionCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Completion>;
11
11
  create(body: CompletionCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<Completion>>;
12
12
  create(body: CompletionCreateParamsBase, options?: Core.RequestOptions): APIPromise<Stream<Completion> | Completion>;
13
13
  }
14
14
  export interface Completion {
15
+ /**
16
+ * Unique object identifier.
17
+ *
18
+ * The format and length of IDs may change over time.
19
+ */
20
+ id: string;
15
21
  /**
16
22
  * The resulting completion up to and excluding the stop sequences.
17
23
  */
18
24
  completion: string;
19
25
  /**
20
- * The model that performed the completion.
26
+ * The model that handled the request.
21
27
  */
22
28
  model: string;
23
29
  /**
24
- * The reason that we stopped sampling.
30
+ * The reason that we stopped.
25
31
  *
26
32
  * This may be one the following values:
27
33
  *
@@ -30,6 +36,7 @@ export interface Completion {
30
36
  * - `"max_tokens"`: we exceeded `max_tokens_to_sample` or the model's maximum
31
37
  */
32
38
  stop_reason: string;
39
+ type: 'completion';
33
40
  }
34
41
  export type CompletionCreateParams = CompletionCreateParamsNonStreaming | CompletionCreateParamsStreaming;
35
42
  export interface CompletionCreateParamsBase {
@@ -43,27 +50,31 @@ export interface CompletionCreateParamsBase {
43
50
  /**
44
51
  * The model that will complete your prompt.
45
52
  *
46
- * As we improve Claude, we develop new versions of it that you can query. This
47
- * parameter controls which version of Claude answers your request. Right now we
48
- * are offering two model families: Claude, and Claude Instant. You can use them by
49
- * setting `model` to `"claude-2"` or `"claude-instant-1"`, respectively. See
50
- * [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
51
- * additional details.
53
+ * As we improve Claude, we develop new versions of it that you can query. The
54
+ * `model` parameter controls which version of Claude responds to your request.
55
+ * Right now we offer two model families: Claude, and Claude Instant. You can use
56
+ * them by setting `model` to `"claude-2.1"` or `"claude-instant-1.2"`,
57
+ * respectively.
58
+ *
59
+ * See [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
60
+ * additional details and options.
52
61
  */
53
- model: (string & {}) | 'claude-2' | 'claude-instant-1';
62
+ model: (string & {}) | 'claude-2.1' | 'claude-instant-1';
54
63
  /**
55
64
  * The prompt that you want Claude to complete.
56
65
  *
57
- * For proper response generation you will need to format your prompt as follows:
66
+ * For proper response generation you will need to format your prompt using
67
+ * alternating `\n\nHuman:` and `\n\nAssistant:` conversational turns. For example:
58
68
  *
59
- * ```javascript
60
- * const userQuestion = r"Why is the sky blue?";
61
- * const prompt = `\n\nHuman: ${userQuestion}\n\nAssistant:`;
69
+ * ```
70
+ * "\n\nHuman: {userQuestion}\n\nAssistant:"
62
71
  * ```
63
72
  *
64
- * See our
65
- * [comments on prompts](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
66
- * for more context.
73
+ * See
74
+ * [prompt validation](https://anthropic.readme.io/claude/reference/prompt-validation)
75
+ * and our guide to
76
+ * [prompt design](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
77
+ * for more details.
67
78
  */
68
79
  prompt: string;
69
80
  /**
@@ -71,7 +82,7 @@ export interface CompletionCreateParamsBase {
71
82
  */
72
83
  metadata?: CompletionCreateParams.Metadata;
73
84
  /**
74
- * Sequences that will cause the model to stop generating completion text.
85
+ * Sequences that will cause the model to stop generating.
75
86
  *
76
87
  * Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
77
88
  * sequences in the future. By providing the stop_sequences parameter, you may
@@ -81,9 +92,8 @@ export interface CompletionCreateParamsBase {
81
92
  /**
82
93
  * Whether to incrementally stream the response using server-sent events.
83
94
  *
84
- * See
85
- * [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
86
- * for details.
95
+ * See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
96
+ * details.
87
97
  */
88
98
  stream?: boolean;
89
99
  /**
@@ -131,9 +141,8 @@ export interface CompletionCreateParamsNonStreaming extends CompletionCreatePara
131
141
  /**
132
142
  * Whether to incrementally stream the response using server-sent events.
133
143
  *
134
- * See
135
- * [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
136
- * for details.
144
+ * See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
145
+ * details.
137
146
  */
138
147
  stream?: false;
139
148
  }
@@ -141,9 +150,8 @@ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsB
141
150
  /**
142
151
  * Whether to incrementally stream the response using server-sent events.
143
152
  *
144
- * See
145
- * [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
146
- * for details.
153
+ * See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
154
+ * details.
147
155
  */
148
156
  stream: true;
149
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"completions.d.ts","sourceRoot":"","sources":["../src/resources/completions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,cAAc,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,kCAAkC,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC;IACvG,MAAM,CACJ,IAAI,EAAE,+BAA+B,EACrC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACjC,MAAM,CACJ,IAAI,EAAE,0BAA0B,EAChC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;CAY/C;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;;OAQG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,GAAG,kCAAkC,GAAG,+BAA+B,CAAC;AAE1G,MAAM,WAAW,0BAA0B;IACzC;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;;;;;OASG;IACH,KAAK,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,UAAU,GAAG,kBAAkB,CAAC;IAEvD;;;;;;;;;;;;;OAaG;IACH,MAAM,EAAE,M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AAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAA4D,CAAC;IAChE,CAAC;CACF;AAxBD,kCAwBC;AA2JD,WAAiB,WAAW;AAK5B,CAAC,EALgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAK3B"}
1
+ {"version":3,"file":"completions.js","sourceRoot":"","sources":["../src/resources/completions.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAIrD,yDAAyD;AAIzD,MAAa,WAAY,SAAQ,sBAAW;IAa1C,MAAM,CACJ,IAA4B,EAC5B,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAA4D,CAAC;IAChE,CAAC;CACF;AAxBD,kCAwBC;AAqKD,WAAiB,WAAW;AAK5B,CAAC,EALgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAK3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"completions.mjs","sourceRoot":"","sources":["../src/resources/completions.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAI9C,EAAE,WAAW,EAAE,MAAM,4BAA4B;AAIxD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAa1C,MAAM,CACJ,IAA4B,EAC5B,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAA4D,CAAC;IAChE,CAAC;CACF;AA2JD,WAAiB,WAAW;AAK5B,CAAC,EALgB,WAAW,KAAX,WAAW,QAK3B"}
1
+ {"version":3,"file":"completions.mjs","sourceRoot":"","sources":["../src/resources/completions.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAI9C,EAAE,WAAW,EAAE,MAAM,4BAA4B;AAIxD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAa1C,MAAM,CACJ,IAA4B,EAC5B,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;SAC7B,CAA4D,CAAC;IAChE,CAAC;CACF;AAqKD,WAAiB,WAAW;AAK5B,CAAC,EALgB,WAAW,KAAX,WAAW,QAK3B"}
@@ -1,2 +1,3 @@
1
+ export { Beta } from "./beta/beta.js";
1
2
  export { Completion, CompletionCreateParams, CompletionCreateParamsNonStreaming, CompletionCreateParamsStreaming, Completions, } from "./completions.js";
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,kCAAkC,EAClC,+BAA+B,EAC/B,WAAW,GACZ,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,kCAAkC,EAClC,+BAA+B,EAC/B,WAAW,GACZ,MAAM,eAAe,CAAC"}
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  // File generated from our OpenAPI spec by Stainless.
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.Completions = void 0;
4
+ exports.Completions = exports.Beta = void 0;
5
+ var beta_1 = require("./beta/beta.js");
6
+ Object.defineProperty(exports, "Beta", { enumerable: true, get: function () { return beta_1.Beta; } });
5
7
  var completions_1 = require("./completions.js");
6
8
  Object.defineProperty(exports, "Completions", { enumerable: true, get: function () { return completions_1.Completions; } });
7
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAErD,gDAMuB;AADrB,0GAAA,WAAW,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAErD,uCAAmC;AAA1B,4FAAA,IAAI,OAAA;AACb,gDAMuB;AADrB,0GAAA,WAAW,OAAA"}
@@ -1,3 +1,4 @@
1
1
  // File generated from our OpenAPI spec by Stainless.
2
+ export { Beta } from "./beta/beta.mjs";
2
3
  export { Completions, } from "./completions.mjs";
3
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAE9C,EAKL,WAAW,GACZ"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAE9C,EAAE,IAAI,EAAE;OACR,EAKL,WAAW,GACZ"}
package/src/error.ts CHANGED
@@ -24,7 +24,8 @@ export class APIError extends AnthropicError {
24
24
  private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
25
25
  const msg =
26
26
  error?.message ?
27
- typeof error.message === 'string' ? error.message
27
+ typeof error.message === 'string' ?
28
+ error.message
28
29
  : JSON.stringify(error.message)
29
30
  : error ? JSON.stringify(error)
30
31
  : message;
package/src/index.ts CHANGED
@@ -19,8 +19,10 @@ export interface ClientOptions {
19
19
 
20
20
  /**
21
21
  * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
22
+ *
23
+ * Defaults to process.env['ANTHROPIC_BASE_URL'].
22
24
  */
23
- baseURL?: string;
25
+ baseURL?: string | null | undefined;
24
26
 
25
27
  /**
26
28
  * The maximum amount of time (in milliseconds) that the client should wait for a response
@@ -82,9 +84,9 @@ export class Anthropic extends Core.APIClient {
82
84
  /**
83
85
  * API Client for interfacing with the Anthropic API.
84
86
  *
85
- * @param {string | null} [opts.apiKey==process.env['ANTHROPIC_API_KEY'] ?? null]
86
- * @param {string | null} [opts.authToken==process.env['ANTHROPIC_AUTH_TOKEN'] ?? null]
87
- * @param {string} [opts.baseURL] - Override the default base URL for the API.
87
+ * @param {string | null} [opts.apiKey=process.env['ANTHROPIC_API_KEY'] ?? null]
88
+ * @param {string | null} [opts.authToken=process.env['ANTHROPIC_AUTH_TOKEN'] ?? null]
89
+ * @param {string} [opts.baseURL=process.env['ANTHROPIC_BASE_URL'] ?? https://api.anthropic.com] - Override the default base URL for the API.
88
90
  * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
89
91
  * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
90
92
  * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
@@ -93,6 +95,7 @@ export class Anthropic extends Core.APIClient {
93
95
  * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
94
96
  */
95
97
  constructor({
98
+ baseURL = Core.readEnv('ANTHROPIC_BASE_URL'),
96
99
  apiKey = Core.readEnv('ANTHROPIC_API_KEY') ?? null,
97
100
  authToken = Core.readEnv('ANTHROPIC_AUTH_TOKEN') ?? null,
98
101
  ...opts
@@ -101,7 +104,7 @@ export class Anthropic extends Core.APIClient {
101
104
  apiKey,
102
105
  authToken,
103
106
  ...opts,
104
- baseURL: opts.baseURL ?? `https://api.anthropic.com`,
107
+ baseURL: baseURL ?? `https://api.anthropic.com`,
105
108
  };
106
109
 
107
110
  super({
@@ -118,6 +121,7 @@ export class Anthropic extends Core.APIClient {
118
121
  }
119
122
 
120
123
  completions: API.Completions = new API.Completions(this);
124
+ beta: API.Beta = new API.Beta(this);
121
125
 
122
126
  protected override defaultQuery(): Core.DefaultQuery | undefined {
123
127
  return this._options.defaultQuery;
@@ -231,6 +235,8 @@ export namespace Anthropic {
231
235
  export import CompletionCreateParams = API.CompletionCreateParams;
232
236
  export import CompletionCreateParamsNonStreaming = API.CompletionCreateParamsNonStreaming;
233
237
  export import CompletionCreateParamsStreaming = API.CompletionCreateParamsStreaming;
238
+
239
+ export import Beta = API.Beta;
234
240
  }
235
241
 
236
242
  export default Anthropic;