@anthropic-ai/sdk 0.4.4 → 0.5.1

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 (156) hide show
  1. package/_shims/agent.d.ts +9 -0
  2. package/_shims/agent.d.ts.map +1 -0
  3. package/_shims/agent.js +14 -0
  4. package/_shims/agent.js.map +1 -0
  5. package/_shims/agent.mjs +10 -0
  6. package/_shims/agent.mjs.map +1 -0
  7. package/_shims/agent.node.d.ts +7 -0
  8. package/_shims/agent.node.d.ts.map +1 -0
  9. package/_shims/agent.node.js +28 -0
  10. package/_shims/agent.node.js.map +1 -0
  11. package/_shims/agent.node.mjs +16 -0
  12. package/_shims/agent.node.mjs.map +1 -0
  13. package/_shims/fetch.d.ts +52 -0
  14. package/_shims/fetch.js +13 -0
  15. package/_shims/fetch.mjs +15 -0
  16. package/_shims/fetch.node.d.ts +53 -0
  17. package/_shims/fetch.node.js +12 -0
  18. package/_shims/fetch.node.mjs +14 -0
  19. package/_shims/fileFromPath.d.ts +22 -0
  20. package/_shims/fileFromPath.d.ts.map +1 -0
  21. package/_shims/fileFromPath.js +16 -0
  22. package/_shims/fileFromPath.js.map +1 -0
  23. package/_shims/fileFromPath.mjs +12 -0
  24. package/_shims/fileFromPath.mjs.map +1 -0
  25. package/_shims/fileFromPath.node.d.ts +17 -0
  26. package/_shims/fileFromPath.node.d.ts.map +1 -0
  27. package/_shims/fileFromPath.node.js +17 -0
  28. package/_shims/fileFromPath.node.js.map +1 -0
  29. package/_shims/fileFromPath.node.mjs +13 -0
  30. package/_shims/fileFromPath.node.mjs.map +1 -0
  31. package/_shims/formdata.d.ts +43 -0
  32. package/_shims/formdata.js +9 -0
  33. package/_shims/formdata.mjs +11 -0
  34. package/_shims/formdata.node.d.ts +44 -0
  35. package/_shims/formdata.node.js +11 -0
  36. package/_shims/formdata.node.mjs +9 -0
  37. package/_shims/getMultipartRequestOptions.d.ts +10 -0
  38. package/_shims/getMultipartRequestOptions.d.ts.map +1 -0
  39. package/_shims/getMultipartRequestOptions.js +12 -0
  40. package/_shims/getMultipartRequestOptions.js.map +1 -0
  41. package/_shims/getMultipartRequestOptions.mjs +8 -0
  42. package/_shims/getMultipartRequestOptions.mjs.map +1 -0
  43. package/_shims/getMultipartRequestOptions.node.d.ts +10 -0
  44. package/_shims/getMultipartRequestOptions.node.d.ts.map +1 -0
  45. package/_shims/getMultipartRequestOptions.node.js +22 -0
  46. package/_shims/getMultipartRequestOptions.node.js.map +1 -0
  47. package/_shims/getMultipartRequestOptions.node.mjs +18 -0
  48. package/_shims/getMultipartRequestOptions.node.mjs.map +1 -0
  49. package/_shims/node-readable.d.ts +23 -0
  50. package/_shims/node-readable.d.ts.map +1 -0
  51. package/_shims/node-readable.js +11 -0
  52. package/_shims/node-readable.js.map +1 -0
  53. package/_shims/node-readable.mjs +7 -0
  54. package/_shims/node-readable.mjs.map +1 -0
  55. package/_shims/node-readable.node.d.ts +8 -0
  56. package/_shims/node-readable.node.d.ts.map +1 -0
  57. package/_shims/node-readable.node.js +9 -0
  58. package/_shims/node-readable.node.js.map +1 -0
  59. package/_shims/node-readable.node.mjs +5 -0
  60. package/_shims/node-readable.node.mjs.map +1 -0
  61. package/core.d.ts +226 -0
  62. package/core.d.ts.map +1 -0
  63. package/core.js +683 -0
  64. package/core.js.map +1 -0
  65. package/core.mjs +587 -0
  66. package/core.mjs.map +1 -0
  67. package/error.d.ts +48 -0
  68. package/error.d.ts.map +1 -0
  69. package/error.js +126 -0
  70. package/error.js.map +1 -0
  71. package/error.mjs +101 -0
  72. package/error.mjs.map +1 -0
  73. package/index.d.mts +104 -0
  74. package/index.d.ts +104 -0
  75. package/index.d.ts.map +1 -0
  76. package/index.js +177 -0
  77. package/index.js.map +1 -0
  78. package/index.mjs +118 -0
  79. package/index.mjs.map +1 -0
  80. package/package.json +73 -23
  81. package/resource.d.ts +12 -0
  82. package/resource.d.ts.map +1 -0
  83. package/resource.js +17 -0
  84. package/resource.js.map +1 -0
  85. package/resource.mjs +13 -0
  86. package/resource.mjs.map +1 -0
  87. package/resources/completions.d.ts +311 -0
  88. package/resources/completions.d.ts.map +1 -0
  89. package/resources/completions.js +19 -0
  90. package/resources/completions.js.map +1 -0
  91. package/resources/completions.mjs +15 -0
  92. package/resources/completions.mjs.map +1 -0
  93. package/resources/index.d.ts +2 -0
  94. package/resources/index.d.ts.map +1 -0
  95. package/resources/index.js +12 -0
  96. package/resources/index.js.map +1 -0
  97. package/resources/index.mjs +3 -0
  98. package/resources/index.mjs.map +1 -0
  99. package/resources/top-level.d.ts +2 -0
  100. package/resources/top-level.d.ts.map +1 -0
  101. package/resources/top-level.js +4 -0
  102. package/resources/top-level.js.map +1 -0
  103. package/resources/top-level.mjs +3 -0
  104. package/resources/top-level.mjs.map +1 -0
  105. package/src/_shims/agent.node.ts +22 -0
  106. package/src/_shims/agent.ts +12 -0
  107. package/src/_shims/fetch.d.ts +52 -0
  108. package/src/_shims/fetch.js +13 -0
  109. package/src/_shims/fetch.mjs +15 -0
  110. package/src/_shims/fetch.node.d.ts +53 -0
  111. package/src/_shims/fetch.node.js +12 -0
  112. package/src/_shims/fetch.node.mjs +14 -0
  113. package/src/_shims/fileFromPath.node.ts +29 -0
  114. package/src/_shims/fileFromPath.ts +29 -0
  115. package/src/_shims/formdata.d.ts +43 -0
  116. package/src/_shims/formdata.js +9 -0
  117. package/src/_shims/formdata.mjs +11 -0
  118. package/src/_shims/formdata.node.d.ts +44 -0
  119. package/src/_shims/formdata.node.js +11 -0
  120. package/src/_shims/formdata.node.mjs +9 -0
  121. package/src/_shims/getMultipartRequestOptions.node.ts +25 -0
  122. package/src/_shims/getMultipartRequestOptions.ts +14 -0
  123. package/src/_shims/node-readable.node.ts +10 -0
  124. package/src/_shims/node-readable.ts +30 -0
  125. package/src/core.ts +783 -0
  126. package/src/error.ts +115 -0
  127. package/src/index.ts +200 -0
  128. package/src/resource.ts +24 -0
  129. package/src/resources/completions.ts +344 -0
  130. package/src/resources/index.ts +3 -0
  131. package/src/resources/top-level.ts +3 -0
  132. package/src/streaming.ts +220 -0
  133. package/src/uploads.ts +248 -0
  134. package/src/version.ts +1 -0
  135. package/streaming.d.ts +14 -0
  136. package/streaming.d.ts.map +1 -0
  137. package/streaming.js +168 -0
  138. package/streaming.js.map +1 -0
  139. package/streaming.mjs +164 -0
  140. package/streaming.mjs.map +1 -0
  141. package/uploads.d.ts +90 -0
  142. package/uploads.d.ts.map +1 -0
  143. package/uploads.js +207 -0
  144. package/uploads.js.map +1 -0
  145. package/uploads.mjs +174 -0
  146. package/uploads.mjs.map +1 -0
  147. package/version.d.ts +2 -0
  148. package/version.d.ts.map +1 -0
  149. package/version.js +5 -0
  150. package/version.js.map +1 -0
  151. package/version.mjs +2 -0
  152. package/version.mjs.map +1 -0
  153. package/LICENSE +0 -21
  154. package/README.md +0 -34
  155. package/build/src/index.d.ts +0 -39
  156. package/build/src/index.js +0 -116
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;;;;;;;;;;;;;;;;;;;;;;;;AAGrD,gDAA+B;AAC/B,0DAAyC;AACzC,mDAAkC;AAElC,sDAAqC;AAyDrC,kCAAkC;AAClC,MAAa,SAAU,SAAQ,IAAI,CAAC,SAAS;IAM3C,YAAY,MAAe;QACzB,MAAM,OAAO,GAAW;YACtB,MAAM,EAAE,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE;YACpF,OAAO,EAAE,2BAA2B;YACpC,GAAG,MAAM;SACV,CAAC;QAEF,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,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kB,GAUhB,MAAM,qBATR,iCAAyB,GASvB,MAAM,4BARR,qBAAa,GAQX,MAAM,gBAPR,qBAAa,GAOX,MAAM,gBANR,sBAAc,GAMZ,MAAM,iBALR,uBAAe,GAKb,MAAM,kBAJR,2BAAmB,GAIjB,MAAM,sBAHR,2BAAmB,GAGjB,MAAM,sBAFR,6BAAqB,GAEnB,MAAM,wBADR,gCAAwB,GACtB,MAAM,0BAAC;AAEG,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACxB,QAAA,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAElD,WAAiB,SAAS;IACxB,mBAAmB;IACL,gBAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACxB,sBAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAEpC,qBAAW,GAAG,GAAG,CAAC,WAAW,CAAC;AAG9C,CAAC,EARgB,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAQzB;AAED,kBAAe,SAAS,CAAC"}
package/index.mjs ADDED
@@ -0,0 +1,118 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ import * as Core from './core.mjs';
3
+ import * as API from './resources/index.mjs';
4
+ import * as Errors from './error.mjs';
5
+ import * as Uploads from './uploads.mjs';
6
+ /** Instantiate the API Client. */
7
+ export class Anthropic extends Core.APIClient {
8
+ constructor(config) {
9
+ const options = {
10
+ apiKey: typeof process === 'undefined' ? '' : process.env['ANTHROPIC_API_KEY'] || '',
11
+ baseURL: 'https://api.anthropic.com',
12
+ ...config,
13
+ };
14
+ super({
15
+ baseURL: options.baseURL,
16
+ timeout: options.timeout,
17
+ httpAgent: options.httpAgent,
18
+ maxRetries: options.maxRetries,
19
+ });
20
+ this.completions = new API.Completions(this);
21
+ this.apiKey = options.apiKey || null;
22
+ this._options = options;
23
+ this.authToken =
24
+ (config === null || config === void 0 ? void 0 : config.authToken) ||
25
+ process.env['ANTHROPIC_AUTH_TOKEN'] ||
26
+ null;
27
+ }
28
+ defaultQuery() {
29
+ return this._options.defaultQuery;
30
+ }
31
+ defaultHeaders() {
32
+ return {
33
+ ...super.defaultHeaders(),
34
+ 'anthropic-version': '2023-06-01',
35
+ ...this._options.defaultHeaders,
36
+ };
37
+ }
38
+ validateHeaders(headers, customHeaders) {
39
+ if (this.apiKey && headers['X-Api-Key']) {
40
+ return;
41
+ }
42
+ if (customHeaders['X-Api-Key'] === null) {
43
+ return;
44
+ }
45
+ if (this.authToken && headers['Authorization']) {
46
+ return;
47
+ }
48
+ if (customHeaders['Authorization'] === null) {
49
+ return;
50
+ }
51
+ throw new Error(
52
+ 'Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted',
53
+ );
54
+ }
55
+ authHeaders() {
56
+ const apiKeyHeader = this.apiKeyHeader();
57
+ if (apiKeyHeader != null && !Core.isEmptyObj(apiKeyHeader)) {
58
+ return apiKeyHeader;
59
+ }
60
+ const authTokenBearer = this.authTokenBearer();
61
+ if (authTokenBearer != null && !Core.isEmptyObj(authTokenBearer)) {
62
+ return authTokenBearer;
63
+ }
64
+ return {};
65
+ }
66
+ apiKeyHeader() {
67
+ if (this.apiKey == null) {
68
+ return {};
69
+ }
70
+ return { 'X-Api-Key': this.apiKey };
71
+ }
72
+ authTokenBearer() {
73
+ if (this.authToken == null) {
74
+ return {};
75
+ }
76
+ return { Authorization: `Bearer ${this.authToken}` };
77
+ }
78
+ qsOptions() {
79
+ return { arrayFormat: 'comma' };
80
+ }
81
+ }
82
+ Anthropic.HUMAN_PROMPT = '\n\nHuman:';
83
+ Anthropic.AI_PROMPT = '\n\nAssistant:';
84
+ Anthropic.APIError = Errors.APIError;
85
+ Anthropic.APIConnectionError = Errors.APIConnectionError;
86
+ Anthropic.APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
87
+ Anthropic.NotFoundError = Errors.NotFoundError;
88
+ Anthropic.ConflictError = Errors.ConflictError;
89
+ Anthropic.RateLimitError = Errors.RateLimitError;
90
+ Anthropic.BadRequestError = Errors.BadRequestError;
91
+ Anthropic.AuthenticationError = Errors.AuthenticationError;
92
+ Anthropic.InternalServerError = Errors.InternalServerError;
93
+ Anthropic.PermissionDeniedError = Errors.PermissionDeniedError;
94
+ Anthropic.UnprocessableEntityError = Errors.UnprocessableEntityError;
95
+ export const { HUMAN_PROMPT, AI_PROMPT } = Anthropic;
96
+ export const {
97
+ APIError,
98
+ APIConnectionError,
99
+ APIConnectionTimeoutError,
100
+ NotFoundError,
101
+ ConflictError,
102
+ RateLimitError,
103
+ BadRequestError,
104
+ AuthenticationError,
105
+ InternalServerError,
106
+ PermissionDeniedError,
107
+ UnprocessableEntityError,
108
+ } = Errors;
109
+ export var toFile = Uploads.toFile;
110
+ export var fileFromPath = Uploads.fileFromPath;
111
+ (function (Anthropic) {
112
+ // Helper functions
113
+ Anthropic.toFile = Uploads.toFile;
114
+ Anthropic.fileFromPath = Uploads.fileFromPath;
115
+ Anthropic.Completions = API.Completions;
116
+ })(Anthropic || (Anthropic = {}));
117
+ export default Anthropic;
118
+ //# sourceMappingURL=index.mjs.map
package/index.mjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,KAAK,IAAI;OACT,KAAK,GAAG;OACR,KAAK,MAAM;OAEX,KAAK,OAAO;AAyDnB,kCAAkC;AAClC,MAAM,OAAO,SAAU,SAAQ,IAAI,CAAC,SAAS;IAM3C,YAAY,MAAe;QACzB,MAAM,OAAO,GAAW;YACtB,MAAM,EAAE,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE;YACpF,OAAO,EAAE,2BAA2B;YACpC,GAAG,MAAM;SACV,CAAC;QAEF,KAAK,CAAC;YACJ,OAAO,EAAE,OAAO,CAAC,OAAQ;YACzB,OAAO,EAAE,OAAO,C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,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;AAErD,MAAM,CAAC,MAAM,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB,GAAG,MAAM,CAAC;AAEX,MAAM,KAAQ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AACtC,MAAM,KAAQ,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;AAElD,WAAiB,SAAS;IACxB,mBAAmB;IACL,gBAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACxB,sBAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAEpC,qBAAW,GAAG,GAAG,CAAC,WAAW,CAAC;AAG9C,CAAC,EARgB,SAAS,KAAT,SAAS,QAQzB;AAED,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,34 +1,84 @@
1
1
  {
2
2
  "name": "@anthropic-ai/sdk",
3
- "version": "0.4.4",
4
- "description": "Library for accessing the Anthropic API",
5
- "repository": "https://github.com/anthropics/anthropic-sdk-typescript",
3
+ "version": "0.5.1",
4
+ "description": "Client library for the Anthropic API",
5
+ "author": "Anthropic <support@anthropic.com>",
6
+ "types": "./index.d.ts",
7
+ "main": "./index.js",
8
+ "type": "commonjs",
9
+ "repository": "github:anthropics/anthropic-sdk-typescript",
6
10
  "license": "MIT",
7
11
  "private": false,
8
- "main": "build/src/index.js",
9
- "types": "build/src/index.d.ts",
10
- "files": [
11
- "build/src/**"
12
- ],
12
+ "exports": {
13
+ "./_shims/*": {
14
+ "deno": {
15
+ "types": "./_shims/*.d.ts",
16
+ "require": "./_shims/*.js",
17
+ "default": "./_shims/*.mjs"
18
+ },
19
+ "browser": {
20
+ "types": "./_shims/*.d.ts",
21
+ "require": "./_shims/*.js",
22
+ "default": "./_shims/*.mjs"
23
+ },
24
+ "worker": {
25
+ "types": "./_shims/*.d.ts",
26
+ "require": "./_shims/*.js",
27
+ "default": "./_shims/*.mjs"
28
+ },
29
+ "workerd": {
30
+ "types": "./_shims/*.d.ts",
31
+ "require": "./_shims/*.js",
32
+ "default": "./_shims/*.mjs"
33
+ },
34
+ "node": {
35
+ "types": "./_shims/*.node.d.ts",
36
+ "require": "./_shims/*.node.js",
37
+ "default": "./_shims/*.node.mjs"
38
+ },
39
+ "types": "./_shims/*.d.ts",
40
+ "require": "./_shims/*.js",
41
+ "default": "./_shims/*.mjs"
42
+ },
43
+ ".": {
44
+ "require": {
45
+ "types": "./index.d.ts",
46
+ "default": "./index.js"
47
+ },
48
+ "types": "./index.d.mts",
49
+ "default": "./index.mjs"
50
+ },
51
+ "./*": {
52
+ "types": "./*.d.ts",
53
+ "require": "./*.js",
54
+ "default": "./*.mjs"
55
+ },
56
+ "./*.js": {
57
+ "types": "./*.d.ts",
58
+ "default": "./*.js"
59
+ },
60
+ "./*.mjs": {
61
+ "types": "./*.d.ts",
62
+ "default": "./*.mjs"
63
+ }
64
+ },
13
65
  "scripts": {
14
- "build": "tsc --build",
15
- "lint": "eslint src && prettier --check .",
66
+ "test": "bin/check-test-server && yarn jest",
67
+ "build": "bash ./build",
16
68
  "format": "prettier --write .",
17
- "example:basic_stream": "tsc --build && node ./build/examples/basic_stream.js",
18
- "example:basic_sync": "tsc --build && node ./build/examples/basic_sync.js",
19
- "example:cancellation": "tsc --build && node ./build/examples/cancellation.js"
69
+ "tsn": "ts-node -r tsconfig-paths/register",
70
+ "fix": "eslint --fix --ext ts,js ."
20
71
  },
21
72
  "dependencies": {
22
- "@fortaine/fetch-event-source": "^3.0.6",
23
- "cross-fetch": "^3.1.5"
24
- },
25
- "devDependencies": {
26
73
  "@types/node": "^18.11.18",
27
- "@typescript-eslint/eslint-plugin": "^5.49.0",
28
- "@typescript-eslint/parser": "^5.49.0",
29
- "dotenv": "^16.0.3",
30
- "eslint": "^8.33.0",
31
- "prettier": "^2.8.3",
32
- "typescript": "^4.9.4"
74
+ "@types/node-fetch": "^2.6.4",
75
+ "@types/qs": "^6.9.7",
76
+ "abort-controller": "^3.0.0",
77
+ "agentkeepalive": "^4.2.1",
78
+ "digest-fetch": "^1.3.0",
79
+ "form-data-encoder": "1.7.2",
80
+ "formdata-node": "^4.3.2",
81
+ "node-fetch": "^2.6.7",
82
+ "qs": "^6.10.3"
33
83
  }
34
84
  }
package/resource.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import type { Anthropic } from './index.js';
2
+ export declare class APIResource {
3
+ protected client: Anthropic;
4
+ constructor(client: Anthropic);
5
+ protected get: Anthropic['get'];
6
+ protected post: Anthropic['post'];
7
+ protected patch: Anthropic['patch'];
8
+ protected put: Anthropic['put'];
9
+ protected delete: Anthropic['delete'];
10
+ protected getAPIList: Anthropic['getAPIList'];
11
+ }
12
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["src/resource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,WAAW;IACtB,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC;gBAChB,MAAM,EAAE,SAAS;IAW7B,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACpC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;CAC/C"}
package/resource.js ADDED
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ exports.APIResource = void 0;
5
+ class APIResource {
6
+ constructor(client) {
7
+ this.client = client;
8
+ this.get = client.get.bind(client);
9
+ this.post = client.post.bind(client);
10
+ this.patch = client.patch.bind(client);
11
+ this.put = client.put.bind(client);
12
+ this.delete = client.delete.bind(client);
13
+ this.getAPIList = client.getAPIList.bind(client);
14
+ }
15
+ }
16
+ exports.APIResource = APIResource;
17
+ //# sourceMappingURL=resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.js","sourceRoot":"","sources":["src/resource.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAIrD,MAAa,WAAW;IAEtB,YAAY,MAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CAQF;AAnBD,kCAmBC"}
package/resource.mjs ADDED
@@ -0,0 +1,13 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ export class APIResource {
3
+ constructor(client) {
4
+ this.client = client;
5
+ this.get = client.get.bind(client);
6
+ this.post = client.post.bind(client);
7
+ this.patch = client.patch.bind(client);
8
+ this.put = client.put.bind(client);
9
+ this.delete = client.delete.bind(client);
10
+ this.getAPIList = client.getAPIList.bind(client);
11
+ }
12
+ }
13
+ //# sourceMappingURL=resource.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.mjs","sourceRoot":"","sources":["src/resource.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAIrD,MAAM,OAAO,WAAW;IAEtB,YAAY,MAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC;CAQF"}
@@ -0,0 +1,311 @@
1
+ import * as Core from '@anthropic-ai/sdk/core';
2
+ import { APIResource } from '@anthropic-ai/sdk/resource';
3
+ import * as API from './index.js';
4
+ import { Stream } from '@anthropic-ai/sdk/streaming';
5
+ export declare class Completions extends APIResource {
6
+ /**
7
+ * Create a completion
8
+ */
9
+ create(
10
+ body: CompletionCreateParams.CompletionRequestNonStreaming,
11
+ options?: Core.RequestOptions,
12
+ ): Promise<Core.APIResponse<Completion>>;
13
+ create(
14
+ body: CompletionCreateParams.CompletionRequestStreaming,
15
+ options?: Core.RequestOptions,
16
+ ): Promise<Core.APIResponse<Stream<Completion>>>;
17
+ }
18
+ export interface Completion {
19
+ /**
20
+ * The resulting completion up to and excluding the stop sequences.
21
+ */
22
+ completion: string;
23
+ /**
24
+ * The model that performed the completion.
25
+ */
26
+ model: string;
27
+ /**
28
+ * The reason that we stopped sampling.
29
+ *
30
+ * This may be one the following values:
31
+ *
32
+ * - `"stop_sequence"`: we reached a stop sequence — either provided by you via the
33
+ * `stop_sequences` parameter, or a stop sequence built into the model
34
+ * - `"max_tokens"`: we exceeded `max_tokens_to_sample` or the model's maximum
35
+ */
36
+ stop_reason: string;
37
+ }
38
+ export type CompletionCreateParams =
39
+ | CompletionCreateParams.CompletionRequestNonStreaming
40
+ | CompletionCreateParams.CompletionRequestStreaming;
41
+ export declare namespace CompletionCreateParams {
42
+ interface CompletionRequestNonStreaming {
43
+ /**
44
+ * The maximum number of tokens to generate before stopping.
45
+ *
46
+ * Note that our models may stop _before_ reaching this maximum. This parameter
47
+ * only specifies the absolute maximum number of tokens to generate.
48
+ */
49
+ max_tokens_to_sample: number;
50
+ /**
51
+ * The model that will complete your prompt.
52
+ *
53
+ * As we improve Claude, we develop new versions of it that you can query. This
54
+ * controls which version of Claude answers your request. Right now we are offering
55
+ * two model families: Claude and Claude Instant.
56
+ *
57
+ * Specifiying any of the following models will automatically switch to you the
58
+ * newest compatible models as they are released:
59
+ *
60
+ * - `"claude-1"`: Our largest model, ideal for a wide range of more complex tasks.
61
+ * - `"claude-1-100k"`: An enhanced version of `claude-1` with a 100,000 token
62
+ * (roughly 75,000 word) context window. Ideal for summarizing, analyzing, and
63
+ * querying long documents and conversations for nuanced understanding of complex
64
+ * topics and relationships across very long spans of text.
65
+ * - `"claude-instant-1"`: A smaller model with far lower latency, sampling at
66
+ * roughly 40 words/sec! Its output quality is somewhat lower than the latest
67
+ * `claude-1` model, particularly for complex tasks. However, it is much less
68
+ * expensive and blazing fast. We believe that this model provides more than
69
+ * adequate performance on a range of tasks including text classification,
70
+ * summarization, and lightweight chat applications, as well as search result
71
+ * summarization.
72
+ * - `"claude-instant-1-100k"`: An enhanced version of `claude-instant-1` with a
73
+ * 100,000 token context window that retains its performance. Well-suited for
74
+ * high throughput use cases needing both speed and additional context, allowing
75
+ * deeper understanding from extended conversations and documents.
76
+ *
77
+ * You can also select specific sub-versions of the above models:
78
+ *
79
+ * - `"claude-1.3"`: Compared to `claude-1.2`, it's more robust against red-team
80
+ * inputs, better at precise instruction-following, better at code, and better
81
+ * and non-English dialogue and writing.
82
+ * - `"claude-1.3-100k"`: An enhanced version of `claude-1.3` with a 100,000 token
83
+ * (roughly 75,000 word) context window.
84
+ * - `"claude-1.2"`: An improved version of `claude-1`. It is slightly improved at
85
+ * general helpfulness, instruction following, coding, and other tasks. It is
86
+ * also considerably better with non-English languages. This model also has the
87
+ * ability to role play (in harmless ways) more consistently, and it defaults to
88
+ * writing somewhat longer and more thorough responses.
89
+ * - `"claude-1.0"`: An earlier version of `claude-1`.
90
+ * - `"claude-instant-1.1"`: Our latest version of `claude-instant-1`. It is better
91
+ * than `claude-instant-1.0` at a wide variety of tasks including writing,
92
+ * coding, and instruction following. It performs better on academic benchmarks,
93
+ * including math, reading comprehension, and coding tests. It is also more
94
+ * robust against red-teaming inputs.
95
+ * - `"claude-instant-1.1-100k"`: An enhanced version of `claude-instant-1.1` with
96
+ * a 100,000 token context window that retains its lightning fast 40 word/sec
97
+ * performance.
98
+ * - `"claude-instant-1.0"`: An earlier version of `claude-instant-1`.
99
+ */
100
+ model: string;
101
+ /**
102
+ * The prompt that you want Claude to complete.
103
+ *
104
+ * For proper response generation you will need to format your prompt as follows:
105
+ *
106
+ * ```javascript
107
+ * const userQuestion = r"Why is the sky blue?";
108
+ * const prompt = `\n\nHuman: ${userQuestion}\n\nAssistant:`;
109
+ * ```
110
+ *
111
+ * See our [comments on prompts](https://console.anthropic.com/docs/prompt-design)
112
+ * for more context.
113
+ */
114
+ prompt: string;
115
+ /**
116
+ * An object describing metadata about the request.
117
+ */
118
+ metadata?: CompletionCreateParams.CompletionRequestNonStreaming.Metadata;
119
+ /**
120
+ * Sequences that will cause the model to stop generating completion text.
121
+ *
122
+ * Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
123
+ * sequences in the future. By providing the stop_sequences parameter, you may
124
+ * include additional strings that will cause the model to stop generating.
125
+ */
126
+ stop_sequences?: Array<string>;
127
+ /**
128
+ * Whether to incrementally stream the response using server-sent events.
129
+ *
130
+ * See
131
+ * [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
132
+ * for details.
133
+ */
134
+ stream?: false;
135
+ /**
136
+ * Amount of randomness injected into the response.
137
+ *
138
+ * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
139
+ * multiple choice, and closer to 1 for creative and generative tasks.
140
+ */
141
+ temperature?: number;
142
+ /**
143
+ * Only sample from the top K options for each subsequent token.
144
+ *
145
+ * Used to remove "long tail" low probability responses.
146
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
147
+ */
148
+ top_k?: number;
149
+ /**
150
+ * Use nucleus sampling.
151
+ *
152
+ * In nucleus sampling, we compute the cumulative distribution over all the options
153
+ * for each subsequent token in decreasing probability order and cut it off once it
154
+ * reaches a particular probability specified by `top_p`. You should either alter
155
+ * `temperature` or `top_p`, but not both.
156
+ */
157
+ top_p?: number;
158
+ }
159
+ namespace CompletionRequestNonStreaming {
160
+ /**
161
+ * An object describing metadata about the request.
162
+ */
163
+ interface Metadata {
164
+ /**
165
+ * An external identifier for the user who is associated with the request.
166
+ *
167
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
168
+ * this id to help detect abuse. Do not include any identifying information such as
169
+ * name, email address, or phone number.
170
+ */
171
+ user_id?: string;
172
+ }
173
+ }
174
+ interface CompletionRequestStreaming {
175
+ /**
176
+ * The maximum number of tokens to generate before stopping.
177
+ *
178
+ * Note that our models may stop _before_ reaching this maximum. This parameter
179
+ * only specifies the absolute maximum number of tokens to generate.
180
+ */
181
+ max_tokens_to_sample: number;
182
+ /**
183
+ * The model that will complete your prompt.
184
+ *
185
+ * As we improve Claude, we develop new versions of it that you can query. This
186
+ * controls which version of Claude answers your request. Right now we are offering
187
+ * two model families: Claude and Claude Instant.
188
+ *
189
+ * Specifiying any of the following models will automatically switch to you the
190
+ * newest compatible models as they are released:
191
+ *
192
+ * - `"claude-1"`: Our largest model, ideal for a wide range of more complex tasks.
193
+ * - `"claude-1-100k"`: An enhanced version of `claude-1` with a 100,000 token
194
+ * (roughly 75,000 word) context window. Ideal for summarizing, analyzing, and
195
+ * querying long documents and conversations for nuanced understanding of complex
196
+ * topics and relationships across very long spans of text.
197
+ * - `"claude-instant-1"`: A smaller model with far lower latency, sampling at
198
+ * roughly 40 words/sec! Its output quality is somewhat lower than the latest
199
+ * `claude-1` model, particularly for complex tasks. However, it is much less
200
+ * expensive and blazing fast. We believe that this model provides more than
201
+ * adequate performance on a range of tasks including text classification,
202
+ * summarization, and lightweight chat applications, as well as search result
203
+ * summarization.
204
+ * - `"claude-instant-1-100k"`: An enhanced version of `claude-instant-1` with a
205
+ * 100,000 token context window that retains its performance. Well-suited for
206
+ * high throughput use cases needing both speed and additional context, allowing
207
+ * deeper understanding from extended conversations and documents.
208
+ *
209
+ * You can also select specific sub-versions of the above models:
210
+ *
211
+ * - `"claude-1.3"`: Compared to `claude-1.2`, it's more robust against red-team
212
+ * inputs, better at precise instruction-following, better at code, and better
213
+ * and non-English dialogue and writing.
214
+ * - `"claude-1.3-100k"`: An enhanced version of `claude-1.3` with a 100,000 token
215
+ * (roughly 75,000 word) context window.
216
+ * - `"claude-1.2"`: An improved version of `claude-1`. It is slightly improved at
217
+ * general helpfulness, instruction following, coding, and other tasks. It is
218
+ * also considerably better with non-English languages. This model also has the
219
+ * ability to role play (in harmless ways) more consistently, and it defaults to
220
+ * writing somewhat longer and more thorough responses.
221
+ * - `"claude-1.0"`: An earlier version of `claude-1`.
222
+ * - `"claude-instant-1.1"`: Our latest version of `claude-instant-1`. It is better
223
+ * than `claude-instant-1.0` at a wide variety of tasks including writing,
224
+ * coding, and instruction following. It performs better on academic benchmarks,
225
+ * including math, reading comprehension, and coding tests. It is also more
226
+ * robust against red-teaming inputs.
227
+ * - `"claude-instant-1.1-100k"`: An enhanced version of `claude-instant-1.1` with
228
+ * a 100,000 token context window that retains its lightning fast 40 word/sec
229
+ * performance.
230
+ * - `"claude-instant-1.0"`: An earlier version of `claude-instant-1`.
231
+ */
232
+ model: string;
233
+ /**
234
+ * The prompt that you want Claude to complete.
235
+ *
236
+ * For proper response generation you will need to format your prompt as follows:
237
+ *
238
+ * ```javascript
239
+ * const userQuestion = r"Why is the sky blue?";
240
+ * const prompt = `\n\nHuman: ${userQuestion}\n\nAssistant:`;
241
+ * ```
242
+ *
243
+ * See our [comments on prompts](https://console.anthropic.com/docs/prompt-design)
244
+ * for more context.
245
+ */
246
+ prompt: string;
247
+ /**
248
+ * Whether to incrementally stream the response using server-sent events.
249
+ *
250
+ * See
251
+ * [this guide to SSE events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events)
252
+ * for details.
253
+ */
254
+ stream: true;
255
+ /**
256
+ * An object describing metadata about the request.
257
+ */
258
+ metadata?: CompletionCreateParams.CompletionRequestStreaming.Metadata;
259
+ /**
260
+ * Sequences that will cause the model to stop generating completion text.
261
+ *
262
+ * Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
263
+ * sequences in the future. By providing the stop_sequences parameter, you may
264
+ * include additional strings that will cause the model to stop generating.
265
+ */
266
+ stop_sequences?: Array<string>;
267
+ /**
268
+ * Amount of randomness injected into the response.
269
+ *
270
+ * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
271
+ * multiple choice, and closer to 1 for creative and generative tasks.
272
+ */
273
+ temperature?: number;
274
+ /**
275
+ * Only sample from the top K options for each subsequent token.
276
+ *
277
+ * Used to remove "long tail" low probability responses.
278
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
279
+ */
280
+ top_k?: number;
281
+ /**
282
+ * Use nucleus sampling.
283
+ *
284
+ * In nucleus sampling, we compute the cumulative distribution over all the options
285
+ * for each subsequent token in decreasing probability order and cut it off once it
286
+ * reaches a particular probability specified by `top_p`. You should either alter
287
+ * `temperature` or `top_p`, but not both.
288
+ */
289
+ top_p?: number;
290
+ }
291
+ namespace CompletionRequestStreaming {
292
+ /**
293
+ * An object describing metadata about the request.
294
+ */
295
+ interface Metadata {
296
+ /**
297
+ * An external identifier for the user who is associated with the request.
298
+ *
299
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
300
+ * this id to help detect abuse. Do not include any identifying information such as
301
+ * name, email address, or phone number.
302
+ */
303
+ user_id?: string;
304
+ }
305
+ }
306
+ }
307
+ export declare namespace Completions {
308
+ export import Completion = API.Completion;
309
+ export import CompletionCreateParams = API.CompletionCreateParams;
310
+ }
311
+ //# sourceMappingURL=completions.d.ts.map
@@ -0,0 +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,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,GAAG,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,qBAAa,WAAY,SAAQ,WAAW;IAC1C;;OAEG;IACH,MAAM,CACJ,IAAI,EAAE,sBAAsB,CAAC,6BAA6B,EAC1D,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACxC,MAAM,CACJ,IAAI,EAAE,sBAAsB,CAAC,0BAA0B,EACvD,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;CAOjD;AAED,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,UAAU,EAAE,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G;QACH,QAAQ,CAAC,EAAE,sBAAsB,CAAC,0BAA0B,CAAC,QAAQ,CAAC;QAEtE;;;;;;WAMG;QACH,cAAc,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAE/B;;;;;WAKG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;;;;WAKG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;QAEf;;;;;;;WAOG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAED,UAAiB,0BAA0B,CAAC;QAC1C;;WAEG;QACH,UAAiB,QAAQ;YACvB;;;;;;eAMG;YACH,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB;KACF;CACF;AAED,yBAAiB,WAAW,CAAC;IAC3B,MAAM,QAAQ,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC;IAC1C,MAAM,QAAQ,sBAAsB,GAAG,GAAG,CAAC,sBAAsB,CAAC;CACnE"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ exports.Completions = void 0;
5
+ const resource_1 = require('@anthropic-ai/sdk/resource');
6
+ class Completions extends resource_1.APIResource {
7
+ create(body, options) {
8
+ var _a;
9
+ return this.post('/v1/complete', {
10
+ body,
11
+ timeout: 600000,
12
+ ...options,
13
+ stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false,
14
+ });
15
+ }
16
+ }
17
+ exports.Completions = Completions;
18
+ (function (Completions) {})((Completions = exports.Completions || (exports.Completions = {})));
19
+ //# sourceMappingURL=completions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completions.js","sourceRoot":"","sources":["../src/resources/completions.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,yDAAyD;AAIzD,MAAa,WAAY,SAAQ,sBAAW;IAY1C,MAAM,CACJ,IAA4B,EAC5B,OAA6B;;QAE7B,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAA,IAAI,CAAC,MAAM,mCAAI,KAAK,EAAE,CAAC,CAAC;IACxG,CAAC;CACF;AAlBD,kCAkBC;AA2TD,WAAiB,WAAW;AAG5B,CAAC,EAHgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAG3B"}
@@ -0,0 +1,15 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ import { APIResource } from '@anthropic-ai/sdk/resource';
3
+ export class Completions extends APIResource {
4
+ create(body, options) {
5
+ var _a;
6
+ return this.post('/v1/complete', {
7
+ body,
8
+ timeout: 600000,
9
+ ...options,
10
+ stream: (_a = body.stream) !== null && _a !== void 0 ? _a : false,
11
+ });
12
+ }
13
+ }
14
+ (function (Completions) {})(Completions || (Completions = {}));
15
+ //# sourceMappingURL=completions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completions.mjs","sourceRoot":"","sources":["../src/resources/completions.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAG9C,EAAE,WAAW,EAAE,MAAM,4BAA4B;AAIxD,MAAM,OAAO,WAAY,SAAQ,WAAW;IAY1C,MAAM,CACJ,IAA4B,EAC5B,OAA6B;;QAE7B,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAA,IAAI,CAAC,MAAM,mCAAI,KAAK,EAAE,CAAC,CAAC;IACxG,CAAC;CACF;AA2TD,WAAiB,WAAW;AAG5B,CAAC,EAHgB,WAAW,KAAX,WAAW,QAG3B"}