The official Node library for the Writer API
Repo writer/writer-node, read from GitHub 18 h ago. writer has not joined Take My Repo.
writer/writer-node is a public repo on GitHub by writer. The official Node library for the Writer API. It declares the Apache-2.0 license on GitHub. It is written mainly in TypeScript, has 12 stars and last changed on 2026-10-23. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
This library provides access to the Writer REST API from server-side TypeScript(>=4.9) or JavaScript.
The REST API documentation can be found on dev.writer.com. The full API of this library can be found in api.md.
It is generated with Stainless.
Use the Writer MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application.
Note: You may need to set environment variables in your MCP client.
npm install writer-sdk
You need a Writer API key to use this library.
"node" environment ("jsdom" is not supported at this time).React Native is not supported at this time.
If you are interested in other runtime environments, please open or upvote an issue on GitHub.
To authenticate with the Writer API, set the WRITER_API_KEY environment variable.
$ export WRITER_API_KEY="my-api-key"
The Writer class automatically infers your API key from the WRITER_API_KEY environment variable.
import Writer from 'writer-sdk';
const client = new Writer();
You can also explicitly set the API key with the apiKey parameter:
import Writer from 'writer-sdk';
const client = new Writer({
apiKey: 'my-api-key',
});
Never hard-code your API keys in source code or commit them to version control systems like GitHub. We recommend adding
WRITER_API_KEY="My API Key"to your.envfile so that your API Key is not stored in source control.
You can find the full API for this library in api.md.
import Writer from 'writer-sdk';
const client = new Writer();
const chatCompletion = await client.chat.chat({
messages: [{ content: 'Write a haiku about programming', role: 'user' }],
model: 'palmyra-x5',
});
console.log(chatCompletion.choices[0].message.content);
}
main();
The SDK also includes helpers to process streams and handle the incoming events.
const runner = writer.chat
.stream({
model: 'palmyra-x5',
messages: [{ role: 'user', content: 'Hi, today I want to write about' }],
})
.on('message', (msg) => console.log(msg))
.on('content', (diff) => process.stdout.write(diff));
const result = await runner.finalChatCompletion();
console.log(result);
More information on streaming helpers can be found in the dedicated documentation: helpers.md
We provide support for streaming responses using Server Sent Events (SSE).
import Writer from 'writer-sdk';
const client = new Writer();
const stream = await client.chat.chat({
messages: [{ content: 'Write a haiku about programming', role: 'user' }],
model: 'palmyra-x5',
stream: true,
});
let outputText = '';
for await (const chunk of stream) {
if (chunk.choices[0]?.delta?.content) {
outputText += chunk.choices[0].delta.content;
} else {
continue;
}
}
console.log(outputText);
If you need to cancel a stream, you can break from the loop
or call stream.controller.abort().
This library includes TypeScript definitions for all request params and response fields. Import and use them like so:
import Writer from 'writer-sdk';
const client = new Writer();
const params: Writer.ChatChatParams = {
messages: [{ content: 'Write a haiku about programming', role: 'user' }],
model: 'palmyra-x5',
};
const chatCompletion: Writer.ChatCompletion = await client.chat.chat(params);
Documentation for each method, request parameter, and response field are available in docstrings and will appear on hover in most modern editors.
Request parameters that correspond to file uploads can be passed in many different forms:
File (or an object with the same structure)fetch Response (or an object with the same structure)fs.ReadStreamtoFile helperThe Content-Type parameter is the MIME type of the file being uploaded. The file upload supports txt, doc, docx, ppt, pptx, jpg, png, eml, html, pdf, srt, csv, xls, and xlsx file extensions.
import fs from 'fs';
import Writer, { toFile } from 'writer-sdk';
const client = new Writer();
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
await client.files.upload({
content: fs.createReadStream('/path/to/file.pdf'),
'Content-Disposition': 'attachment; filename="example.pdf"',
'Content-Type': 'application/pdf',
});
// If you have the web `File` API you can pass a `File` instance:
await client.files.upload({
content: new File(['my bytes'], 'example.txt'),
'Content-Disposition': 'attachment; filename="example.txt"',
'Content-Type': 'text/plain',
});
// You can also pass a `fetch` `Response`:
await client.files.upload({
content: await fetch('https://example.com/example.pdf'),
'Content-Disposition': 'attachment; filename="example.pdf"',
'Content-Type': 'application/pdf',
});
// Finally, if none of the above are convenient, you can use our `toFile` helper:
await client.files.upload({
content: await toFile(Buffer.from('my bytes'), 'example.txt'),
'Content-Disposition': 'attachment; filename="example.txt"',
'Content-Type': 'text/plain',
});
await client.files.upload({
content: await toFile(new Uint8Array([0, 1, 2]), 'example.txt'),
'Content-Disposition': 'attachment; filename="example.txt"',
'Content-Type': 'text/plain',
});
When the library is unable to connect to the API (for example, due to a network connectivity problem or a firewall that doesn't allow the connection),
or if the API returns a non-success status code (4xx or 5xx response),
a subclass of APIError will be thrown.
If you are behind a firewall, you may need to configure it to allow connections to the Writer API at
https://api.writer.com/v1.
const chatCompletion = await client.chat
.chat({
messages: [{ content: 'Write a haiku about programming', role: 'user' }],
model: 'palmyra-x5',
})
.catch(async (err) => {
if (err instanceof Writer.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
} else {
throw err;
}
});
Error codes are as follows:
| Status Code | Error Type |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 403 | PermissionDeniedError |
| 404 | NotFoundError |
| 422 | UnprocessableEntityError |
| 429 | RateLimitError |
| >=500 | InternalServerError |
| N/A | APIConnectionError |
Certain errors will be automatically retried 7 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default.
You can use the maxRetries option to configure or disable this:
// Configure the default for all requests:
const client = new Writer({
maxRetries: 0, // default is 2
});
// Or, configure per-request:
await client.chat.chat({ messages: [{ content: 'Write a haiku about programming', role: 'user' }], model: 'palmyra-x5' }, {
maxRetries: 5,
});
Requests time out after three minutes by default. You can configure this with a timeout option:
// Configure the default for all requests:
const client = new Writer({
timeout: 20 * 1000, // 20 seconds (default is 3 minutes)
});
// Override per-request:
await client.chat.chat({ messages: [{ content: 'Write a haiku about programming', role: 'user' }], model: 'palmyra-x5' }, {
timeout: 5 * 1000,
});
On timeout, an APIConnectionTimeoutError is thrown.
Requests that time out will be retried twice by default.
List methods in the Writer API are paginated.
You can use the for await … of syntax to iterate through items across all pages:
async function fetchAllGraphs(params) {
const allGraphs = [];
// Automatically fetches more pages as needed.
for await (const graph of client.graphs.list()) {
allGraphs.push(graph);
}
return allGraphs;
}
Alternatively, you can request a single page at a time:
let page = await client.graphs.list();
for (const graph of page.data) {
console.log(graph);
}
// Convenience methods are provided for manually paginating:
while (page.hasNextPage()) {
page = await page.getNextPage();
// ...
}
When you use fetch() to make requests, you can access the raw Response through the .asResponse() method on the APIPromise type that all methods return.
This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.
You can also use the .withResponse() method to get the raw Response along with the parsed data.
Unlike .asResponse() this method consumes the body, returning once it is parsed.
const client = new Writer();
const response = await client.chat
.chat({
messages: [{ content: 'Write a haiku about programming', role: 'user' }],
model: 'palmyra-x5',
})
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object
const { data: chatCompletion, response: raw } = await client.chat
.chat({
messages: [{ content: 'Write a haiku about programming', role: 'user' }],
model: 'palmyra-x5',
})
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(chatCompletion.id);
[!IMPORTANT] All log messages are intended for debugging only. The format and content of log messages may change between releases.
The log level can be configured in two ways:
WRITER_LOG environment variablelogLevel client option (overrides the environment variable if set)import Writer from 'writer-sdk';
const client = new Writer({
logLevel: 'debug', // Show all log messages
});
Available log levels, from most to least verbose:
'debug' - Show debug messages, info, warnings, and errors'info' - Show info messages, warnings, and errors'warn' - Show warnings and errors (default)'error' - Show only errors'off' - Disable all loggingAt the 'debug' level, all HTTP requests and responses are logged, including headers and bodies.
Some authentication-related headers are redacted, but sensitive data in request and response bodies
may still be visible.
By default, this library logs to globalThis.console. You can also provide a custom logger.
Most logging libraries are supported, including pino, winston, bunyan, consola, signale, and @std/log. If your logger doesn't work, please open an issue.
When providing a custom logger, the logLevel option still controls which messages are emitted, messages
below the configured level will not be sent to your logger.
import Writer from 'writer-sdk';
import pino from 'pino';
const logger = pino();
const client = new Writer({
logger: logger.child({ name: 'Writer' }),
logLevel: 'debug', // Send all messages to pino, allowing it to filter
});
This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, parameters, or response properties, you can still use the library.
To make requests to undocumented endpoints, use client.get, client.post
writer/writer-node is a public repo on GitHub by writer. The official Node library for the Writer API.
It declares the Apache-2.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-10-23. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Take My Repo cannot say: it does not audit code and has not run writer-node. What is known comes from GitHub. It declares the Apache-2.0 license on GitHub. Its last change was on 2026-10-23. It has 12 stars, which measure popularity, not safety. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read the source before you run it. With "Take it", your AI agent shows each step and asks you before running it; README text is treated as data, not as instructions.