{"_id":"@writerai/writer-sdk","_rev":"14-eac186a68485ba221a5947fed9318536","name":"@writerai/writer-sdk","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_2.2.2_1703007479823_0.9078454878879079","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"2.2.3":{"name":"@writerai/writer-sdk","version":"2.2.3","keywords":[],"author":{"name":"writerai"},"_id":"@writerai/writer-sdk@2.2.3","maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"dist":{"shasum":"32670b7e253fcb0028e3eddf74fbe5e8ad44bf26","tarball":"https://registry.npmjs.org/@writerai/writer-sdk/-/writer-sdk-2.2.3.tgz","fileCount":669,"integrity":"sha512-bdla4K8/ADcRRLQJmkrK1NeuSZQB2l8PoY6H99EEVY4jNo1qmeDBU0hpebO7ETX6mauzPV67ZG6IytCc+RqpPg==","signatures":[{"sig":"MEQCIFlG84EDInqYv+B6wOElrVpcjcU+4VdcO/2a8V3ik9ZOAiBtJpTajrsI8FR/cocn31cy6g43y5i6Qm4fVj3dKDuUIw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1683617},"main":"./index.js","type":"commonjs","types":"./index.d.ts","gitHead":"a556e5ee0eb1a4a00524de743a665671b6caceb1","scripts":{"lint":"eslint --max-warnings=0 src","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"wassemgtk","email":"wassem@gmail.com"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"_npmVersion":"8.19.4","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_2.2.3_1703613194630_0.030237507258718654","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"3.0.0":{"name":"@writerai/writer-sdk","version":"3.0.0","keywords":[],"author":{"name":"writerai"},"_id":"@writerai/writer-sdk@3.0.0","maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"dist":{"shasum":"39309190dcf931a3fa17932b60aed9c61b142754","tarball":"https://registry.npmjs.org/@writerai/writer-sdk/-/writer-sdk-3.0.0.tgz","fileCount":675,"integrity":"sha512-Yk+9A3AYi4DOCQ69fzuTZzvBIFOvE+6rRiQ4vtHB9cU3RUJPcSr/0ic3ESokRB8mlp9irPYM5/sKmmnVMD1xrg==","signatures":[{"sig":"MEYCIQC5jfCPMPuTrTsKLbdcHZHu4H8uwNuQL1OJBGLFRZ4ZawIhAKe9rdCuSwmZLY+uLz3AtlQoYM5/DaJBLdpFhtqcbz6b","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1761394},"main":"./index.js","type":"commonjs","types":"./index.d.ts","gitHead":"5c104779a89a31537bf234bb939e984f902c5e0c","scripts":{"lint":"eslint --max-warnings=0 src","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"wassemgtk","email":"wassem@gmail.com"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"_npmVersion":"8.19.4","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_3.0.0_1705676238348_0.6402225270557287","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"3.0.1":{"name":"@writerai/writer-sdk","version":"3.0.1","keywords":[],"author":{"name":"writerai"},"_id":"@writerai/writer-sdk@3.0.1","maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"dist":{"shasum":"25aadd73a0c6c3043acdd79eb5a495e91886b640","tarball":"https://registry.npmjs.org/@writerai/writer-sdk/-/writer-sdk-3.0.1.tgz","fileCount":675,"integrity":"sha512-LNX67AScGOB9ZcI4nRvpjJpL0A2MZBl0M0CI5LP6EekziKgtdI7stK9omSlfxGenAuyTCBDYl6UggeV6zwn5xA==","signatures":[{"sig":"MEUCIDguAJr4Yn8J4n7zra5hrUqVpdsEdJbX2Rxq8+weTKxoAiEAz/nQ4LKPbWRWIL90zkLTX9kqRDq8Au7+Kf+BZ4yDvS4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1761333},"main":"./index.js","type":"commonjs","types":"./index.d.ts","gitHead":"8af5aa328b6469cb47f6e9a3de1ac087d002177b","scripts":{"lint":"eslint --max-warnings=0 src","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"wassemgtk","email":"wassem@gmail.com"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"_npmVersion":"8.19.4","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_3.0.1_1707436134126_0.4692898546362607","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"3.4.2":{"name":"@writerai/writer-sdk","version":"3.4.2","keywords":[],"author":{"name":"writerai"},"_id":"@writerai/writer-sdk@3.4.2","maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"dist":{"shasum":"f886089dc029ec0dd0c11b57990167dfdfae4e9f","tarball":"https://registry.npmjs.org/@writerai/writer-sdk/-/writer-sdk-3.4.2.tgz","fileCount":695,"integrity":"sha512-9YwzMitjeKPNWrR9P42xMhAETv6U2J3igAWfsRHIgAuyOs/NafcJqD16BsVGkp413lrRSb421MyzSYvuJ1PADg==","signatures":[{"sig":"MEUCICb8WjIgvGWMxpzh3FUSOpYMrtmY0Ey9ETUgEmkfurzYAiEAlmpjcm/1XSH1a8l1gh+BmK5SsKWhqILqxXiTTIP0dHE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1932940},"main":"./index.js","types":"./index.d.ts","gitHead":"cb9c8c70397f173170ad35a74f13d2a076a9bf18","scripts":{"lint":"eslint --max-warnings=0 src","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"wassemgtk","email":"wassem@gmail.com"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"_npmVersion":"8.19.4","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_3.4.2_1711463425757_0.12002156805550679","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"3.5.0":{"name":"@writerai/writer-sdk","version":"3.5.0","author":{"name":"writerai"},"_id":"@writerai/writer-sdk@3.5.0","maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"dist":{"shasum":"1743b80356d7ea194c18310a61603947f96a8219","tarball":"https://registry.npmjs.org/@writerai/writer-sdk/-/writer-sdk-3.5.0.tgz","fileCount":692,"integrity":"sha512-sIRk6JzgNlZHt9ghHt/TFHGIMaJKHQWs1lz7PZ0coDhQ51F1FovcpHjDa7Em4xE01MAOoZYV/VRswtPLF2hnAw==","signatures":[{"sig":"MEUCIQD3YJZgKZ1TVoL3TAOrRCeT3disLdW4ZwDFdNYPSNJ7OgIgNe6ef3XTywTcgi76awxo/UxB7wd97Dra0ifXkI5KXoc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1919853},"main":"./index.js","types":"./index.d.ts","gitHead":"629ce58816b6a470e34b4b02e02d012c3cf435e0","scripts":{"lint":"eslint --max-warnings=0 src","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"wassemgtk","email":"wassem@gmail.com"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"_npmVersion":"8.19.4","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_3.5.0_1713971837693_0.7088557922232572","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"3.6.0":{"name":"@writerai/writer-sdk","version":"3.6.0","author":{"name":"writerai"},"_id":"@writerai/writer-sdk@3.6.0","maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"dist":{"shasum":"2842a1eda24a507d71a31b5b46372675137e3c41","tarball":"https://registry.npmjs.org/@writerai/writer-sdk/-/writer-sdk-3.6.0.tgz","fileCount":707,"integrity":"sha512-BEVNVPy9nkwm7jQRij/s6pexkHqAwX7TsYKTPiLZXzHVsJZEfDNMHT0nJReEYh8RjuE1ZMfcbMb4B36RIq2rZw==","signatures":[{"sig":"MEQCICxGAik2M/CabIKTeb71qwhyGy85DpnptOoGXjPW2kYeAiAz5JgnUeSNhpVmqT/cETz1zM6Q3G7v/J0T3aoVQmNG0Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1863297},"main":"./index.js","types":"./index.d.ts","gitHead":"2b532332779c3cc8719081a38a8714bcf89fdb82","scripts":{"lint":"eslint --max-warnings=0 src","build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"wassemgtk","email":"wassem@gmail.com"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"_npmVersion":"8.19.4","description":"
= 3"},"_npmOperationalInternal":{"tmp":"tmp/writer-sdk_3.6.0_1714498481899_0.9785980372156882","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2023-04-17T12:53:13.745Z","modified":"2024-06-13T15:15:56.092Z","0.3.0":"2023-04-17T12:53:14.098Z","0.25.0":"2023-06-28T20:43:07.816Z","0.40.2":"2023-08-25T19:54:07.260Z","0.41.1":"2023-08-31T00:02:47.327Z","0.48.1":"2023-10-12T16:28:17.269Z","1.1.0":"2023-10-12T18:31:59.216Z","2.0.2":"2023-11-11T19:29:25.971Z","2.2.2":"2023-12-19T17:38:00.157Z","2.2.3":"2023-12-26T17:53:14.906Z","3.0.0":"2024-01-19T14:57:18.592Z","3.0.1":"2024-02-08T23:48:54.507Z","3.4.2":"2024-03-26T14:30:26.016Z","3.5.0":"2024-04-24T15:17:17.898Z","3.6.0":"2024-04-30T17:34:42.199Z"},"maintainers":[{"name":"muayad","email":"moayad@writer.com"},{"name":"wassemgtk","email":"wassem@gmail.com"}],"author":{"name":"writerai"},"repository":{"url":"git+https://github.com/writerai/writer-client-sdk-typescript.git","type":"git","directory":"."},"homepage":"https://github.com/writerai/writer-client-sdk-typescript#readme","bugs":{"url":"https://github.com/writerai/writer-client-sdk-typescript/issues"},"readme":"
\n \n \n \n \n

Typescript SDK

\n

AI for everyone.

\n \n \n \n
\n\n\n## SDK Installation\n\n### NPM\n\n```bash\nnpm add @writerai/writer-sdk\n```\n\n### Yarn\n\n```bash\nyarn add @writerai/writer-sdk\n```\n\n\n## Authentication\n\nWriter authenticates your API requests using your account’s API keys. If you do not include your key when making an API request, or use one that is incorrect or outdated, Writer returns an error.\n\nYour API keys are available in the account dashboard. We include randomly generated API keys in our code examples if you are not logged in. Replace these with your own or log in to see code examples populated with your own API keys.\n\n\"writer-auth\"\n\nIf you cannot see your secret API keys in the Dashboard, this means you do not have access to them. Contact your Writer account owner and ask to be added to their team as a developer.\n\n\n## SDK Example Usage\n\n### Example\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\n\nconst writer = new Writer({\n apiKey: \"\",\n organizationId: 850421,\n});\n\nasync function run() {\n const result = await writer.billing.getSubscriptionDetails();\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n\n## Available Resources and Operations\n\n### [billing](docs/sdks/billing/README.md)\n\n* [getSubscriptionDetails](docs/sdks/billing/README.md#getsubscriptiondetails) - Get your organization subscription details\n\n### [aiContentDetector](docs/sdks/aicontentdetector/README.md)\n\n* [detect](docs/sdks/aicontentdetector/README.md#detect) - Content detector api\n\n### [content](docs/sdks/content/README.md)\n\n* [check](docs/sdks/content/README.md#check) - Check your content against your preset styleguide.\n* [correct](docs/sdks/content/README.md#correct) - Apply the style guide suggestions directly to your content.\n\n### [coWrite](docs/sdks/cowrite/README.md)\n\n* [generateContent](docs/sdks/cowrite/README.md#generatecontent) - Generate content using predefined templates\n* [listTemplates](docs/sdks/cowrite/README.md#listtemplates) - Get a list of your existing CoWrite templates\n\n### [files](docs/sdks/files/README.md)\n\n* [delete](docs/sdks/files/README.md#delete) - Delete file\n* [get](docs/sdks/files/README.md#get) - Get file\n* [list](docs/sdks/files/README.md#list) - List files\n* [upload](docs/sdks/files/README.md#upload) - Upload file\n\n### [models](docs/sdks/models/README.md)\n\n* [list](docs/sdks/models/README.md#list) - List available LLM models\n\n### [completions](docs/sdks/completions/README.md)\n\n* [create](docs/sdks/completions/README.md#create) - Create completion for LLM model\n* [createModelCustomizationCompletion](docs/sdks/completions/README.md#createmodelcustomizationcompletion) - Create completion for LLM customization model\n* [stream](docs/sdks/completions/README.md#stream) - Create streaming completion for LLM model\n\n### [modelCustomization](docs/sdks/modelcustomization/README.md)\n\n* [create](docs/sdks/modelcustomization/README.md#create) - Create model customization\n* [delete](docs/sdks/modelcustomization/README.md#delete) - Delete Model customization\n* [get](docs/sdks/modelcustomization/README.md#get) - Get model customization\n* [list](docs/sdks/modelcustomization/README.md#list) - List model customizations\n\n### [downloadTheCustomizedModel](docs/sdks/downloadthecustomizedmodel/README.md)\n\n* [fetchFile](docs/sdks/downloadthecustomizedmodel/README.md#fetchfile) - Download your fine-tuned model (available only for Palmyra Base and Palmyra Large)\n\n### [document](docs/sdks/document/README.md)\n\n* [get](docs/sdks/document/README.md#get) - Get document details\n* [list](docs/sdks/document/README.md#list) - List team documents\n\n### [snippet](docs/sdks/snippet/README.md)\n\n* [delete](docs/sdks/snippet/README.md#delete) - Delete snippets\n* [find](docs/sdks/snippet/README.md#find) - Find snippets\n* [update](docs/sdks/snippet/README.md#update) - Update snippets\n\n### [styleguide](docs/sdks/styleguide/README.md)\n\n* [get](docs/sdks/styleguide/README.md#get) - Page details\n* [listPages](docs/sdks/styleguide/README.md#listpages) - List your styleguide pages\n\n### [terminology](docs/sdks/terminology/README.md)\n\n* [add](docs/sdks/terminology/README.md#add) - Add terms\n* [delete](docs/sdks/terminology/README.md#delete) - Delete terms\n* [find](docs/sdks/terminology/README.md#find) - Find terms\n* [update](docs/sdks/terminology/README.md#update) - Update terms\n\n### [user](docs/sdks/user/README.md)\n\n* [list](docs/sdks/user/README.md#list) - List users\n\n\n\n\n\n\n\n\n\n## Global Parameters\n\nA parameter is configured globally. This parameter must be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.\n\nFor example, you can set `organizationId` to `99895` at SDK initialization and then you do not have to pass the same value on calls to operations like `detect`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.\n\n\n### Available Globals\n\nThe following global parameter is available. The required parameter must be set when you initialize the SDK client.\n\n| Name | Type | Required | Description |\n| ---- | ---- |:--------:| ----------- |\n| organizationId | number | ✔️ | The organizationId parameter. |\n\n\n### Example\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\n\nconst writer = new Writer({\n apiKey: \"\",\n organizationId: 496531,\n});\n\nasync function run() {\n const contentDetectorRequest = {\n input: \"\",\n };\n const organizationId = 592237;\n\n const result = await writer.aiContentDetector.detect(contentDetectorRequest, organizationId);\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n\n\n\n## Error Handling\n\nAll SDK methods return a response object or throw an error. If Error objects are specified in your OpenAPI Spec, the SDK will throw the appropriate Error type.\n\n| Error Object | Status Code | Content Type |\n| ------------------- | ------------------- | ------------------- |\n| errors.FailResponse | 400,401,403,404,500 | application/json |\n| errors.SDKError | 4xx-5xx | */* |\n\nValidation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging. \n\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\nimport * as errors from \"@writerai/writer-sdk/sdk/models/errors\";\n\nconst writer = new Writer({\n apiKey: \"\",\n organizationId: 850421,\n});\n\nasync function run() {\n let result;\n try {\n result = await writer.billing.getSubscriptionDetails();\n } catch (err) {\n switch (true) {\n case err instanceof errors.SDKValidationError: {\n // Validation errors can be pretty-printed\n console.error(err.pretty());\n // Raw value may also be inspected\n console.error(err.rawValue);\n return;\n }\n case err instanceof errors.FailResponse: {\n console.error(err); // handle exception\n return;\n }\n default: {\n throw err;\n }\n }\n }\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n\n\n\n## Server Selection\n\n### Select Server by Index\n\nYou can override the default server globally by passing a server index to the `serverIdx` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:\n\n| # | Server | Variables |\n| - | ------ | --------- |\n| 0 | `https://enterprise-api.writer.com` | None |\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\n\nconst writer = new Writer({\n serverIdx: 0,\n apiKey: \"\",\n organizationId: 850421,\n});\n\nasync function run() {\n const result = await writer.billing.getSubscriptionDetails();\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n### Override Server URL Per-Client\n\nThe default server can also be overridden globally by passing a URL to the `serverURL` optional parameter when initializing the SDK client instance. For example:\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\n\nconst writer = new Writer({\n serverURL: \"https://enterprise-api.writer.com\",\n apiKey: \"\",\n organizationId: 850421,\n});\n\nasync function run() {\n const result = await writer.billing.getSubscriptionDetails();\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n\n\n\n## Custom HTTP Client\n\nThe TypeScript SDK makes API calls using an `HTTPClient` that wraps the native\n[Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). This\nclient is a thin wrapper around `fetch` and provides the ability to attach hooks\naround the request lifecycle that can be used to modify the request or handle\nerrors and response.\n\nThe `HTTPClient` constructor takes an optional `fetcher` argument that can be\nused to integrate a third-party HTTP client or when writing tests to mock out\nthe HTTP client and feed in fixtures.\n\nThe following example shows how to use the `\"beforeRequest\"` hook to to add a\ncustom header and a timeout to requests and how to use the `\"requestError\"` hook\nto log errors:\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\nimport { HTTPClient } from \"@writerai/writer-sdk/lib/http\";\n\nconst httpClient = new HTTPClient({\n // fetcher takes a function that has the same signature as native `fetch`.\n fetcher: (request) => {\n return fetch(request);\n }\n});\n\nhttpClient.addHook(\"beforeRequest\", (request) => {\n const nextRequest = new Request(request, {\n signal: request.signal || AbortSignal.timeout(5000);\n });\n\n nextRequest.headers.set(\"x-custom-header\", \"custom value\");\n\n return nextRequest;\n});\n\nhttpClient.addHook(\"requestError\", (error, request) => {\n console.group(\"Request Error\");\n console.log(\"Reason:\", `${error}`);\n console.log(\"Endpoint:\", `${request.method} ${request.url}`);\n console.groupEnd();\n});\n\nconst sdk = new Writer({ httpClient });\n```\n\n\n\n\n\n## Authentication\n\n### Per-Client Security Schemes\n\nThis SDK supports the following security scheme globally:\n\n| Name | Type | Scheme |\n| -------- | -------- | -------- |\n| `apiKey` | apiKey | API key |\n\nTo authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example:\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\n\nconst writer = new Writer({\n apiKey: \"\",\n organizationId: 850421,\n});\n\nasync function run() {\n const result = await writer.billing.getSubscriptionDetails();\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n\n## File uploads\n\nCertain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.\n\n> [!TIP]\n>\n> Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:\n>\n> - **Node.js v20+:** Since v20, Node.js comes with a native `openAsBlob` function in [`node:fs`](https://nodejs.org/docs/latest-v20.x/api/fs.html#fsopenasblobpath-options).\n> - **Bun:** The native [`Bun.file`](https://bun.sh/docs/api/file-io#reading-files-bun-file) function produces a file handle that can be used for streaming file uploads.\n> - **Browsers:** All supported browsers return an instance to a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) when reading the value from an `` element.\n> - **Node.js v18:** A file stream can be created using the `fileFrom` helper from [`fetch-blob/from.js`](https://www.npmjs.com/package/fetch-blob).\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\nimport { openAsBlob } from \"node:fs\";\n\nconst writer = new Writer({\n apiKey: \"\",\n organizationId: 403654,\n});\n\nasync function run() {\n const uploadModelFileRequest = {\n file: await openAsBlob(\"./sample-file\"),\n };\n const organizationId = 330343;\n\n const result = await writer.files.upload(uploadModelFileRequest, organizationId);\n\n // Handle the result\n console.log(result);\n}\n\nrun();\n\n```\n\n\n\n## Requirements\n\nFor supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).\n\n\n\n## Server-sent event streaming\n\n[Server-sent events][mdn-sse] are used to stream content from certain\noperations. These operations will expose the stream as an async iterable that\ncan be consumed using a [`for await...of`][mdn-for-await-of] loop. The loop will\nterminate when the server no longer has any events to send and closes the\nunderlying connection.\n\n```typescript\nimport { Writer } from \"@writerai/writer-sdk\";\n\nconst writer = new Writer({\n apiKey: \"\",\n organizationId: 824292,\n});\n\nasync function run() {\n const completionRequest = {\n bestOf: 1,\n maxTokens: 1024,\n minTokens: 1,\n prompt: \"\",\n stop: [\"the\", \"is\", \"and\"],\n temperature: 0.7,\n topP: 1,\n };\n const modelId = \"\";\n const organizationId = 806561;\n\n const result = await writer.completions.stream(completionRequest, modelId, organizationId);\n\n if (res.completionEvent == null) {\n throw new Error(\"failed to create stream: received null value\");\n }\n\n for await (const event of res.completionEvent) {\n // Handle the event\n }\n}\n\nrun();\n\n```\n\n[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events\n[mdn-for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n\n\n\n\n\n\n### SDK Generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)\n","readmeFilename":"README.md"}