## Documentation Index

Fetch the complete documentation index at: [/llms.txt](https://dev.writer.com/llms.txt)

Use this file to discover all available pages before exploring further.

This guide helps you get started with the Writer SDKs. Follow these steps to install the SDKs and perform basic operations.

### Prerequisites

- Python SDK
- Node SDK
- Python 3.7+
- [pip](https://pypi.org/project/pip/)
- A Writer API key
- Node.js
- [`npm`](https://www.npmjs.com/get-npm)
- A Writer API key

You need an API key to access the Writer API. Get an API key by following the steps in the [API quickstart](https://dev.writer.com/home/quickstart). We recommend setting the API key as an environment variable in a `.env` file with the name `WRITER_API_KEY`.

### Install the SDK

Open your terminal or command prompt and install the Writer SDK:

Python

```
pip install writer-sdk
```

Node

```
npm install writer-sdk
```

## Initialize the client

To initialize the client, import the Writer SDK and create an instance of the `Writer` class. We recommend setting your API key in an environment variable called `WRITER_API_KEY`. When you initialize the Writer client, the client looks for the `WRITER_API_KEY` environment variable automatically. You can also pass your API key directly to the client.

Python

```
from writerai import Writer

# Initialize the client. If you don't pass the `api_key` parameter,
# the client looks for the `WRITER_API_KEY` environment variable.
client = Writer()
```

JavaScript

```
import { Writer } from 'writer-sdk';
// Initialize the client. If you don't pass the `api_key` parameter,
// the client looks for the `WRITER_API_KEY` environment variable.
const client = new Writer();
```

## Make a chat completion request

Once you’ve initialized the client, you can make a request to the Writer API. The following example shows how to make a [chat completion request](https://dev.writer.com/home/chat-completion) to generate a poem:

Python

```
from writerai import Writer

client = Writer()

response = client.chat.chat(
    messages=[{ "content": "Write a short poem about Python", "role": 'user' }],
    model="palmyra-x5"
)

print(response.choices[0].message.content)
```

JavaScript

```
import { Writer } from 'writer-sdk';

const client = new Writer();

const response = await client.chat.chat({
    messages: [{ content: "Write a short poem about JavaScript", role: 'user' }],
    model: "palmyra-x5"
});

console.log(response.choices[0].message.content);
```

## Next steps

Now that you’re set up with the SDKs, start building with [chat completions](https://dev.writer.com/home/chat-completion) or [text generation](https://dev.writer.com/home/text-generation). You can also use the [API reference](https://dev.writer.com/api-reference) to learn more detailed information about available endpoints.
