SDKs
This guide will help you get started with the Writer SDKs. Follow these steps to install the SDKs and perform basic operations.
Your API key can be generated using these steps.
Prerequisites
- Python 3.7 or higher and pip installed on your system
- A Writer API key
Installation
Open your terminal or command prompt and install the Writer SDK using npm:
Setting up the Writer client
Create a new file
Create a new Python file (e.g., writer-test.py
).
Import and initialize
Import the Writer SDK and create a client instance, replacing your-api-key
with your actual API key:
For production usage, we recommend using a library like python-dotenv to manage your API key in a .env
file as WRITER_API_KEY
.
Basic usage: Chat completion
To get started using Writer LLMs and the API, perform a basic chat completion task.
Add chat completion code
Add the following code to your file:
Run the script
Save the file and run it using Python:
You should see the chat response streaming to the console.
For advanced SDK usage, such as custom requests or configuring retries and timeouts, refer to the README file in the GitHub repository.
Next steps
Now that you’re set up with the SDKs, check out the guides on text generation, applications, and Knowledge Graph to explore more advanced features of the Writer platform. You can also use the API reference to learn more detailed information about available endpoints.