Skip to main content
This guide shows you how to make your first API calls to the Writer API. After you create an API key in Control Center, you can generate text with the chat completion endpoint.
Deprecation notice: Legacy API keys (keys created under the previous API agent model) will stop working on December 1, 2026.Migration path: Create a new API key, update your applications to use the new key, then revoke the legacy key.

Get an API key

Before you can make API calls, create an API key in Control Center.
1

Navigate to API Keys

From the Control Center home page, open Security & compliance in the left sidebar, then select API Keys.
2

Open Generate an API Key

Select New to open the Generate an API Key page.
3

Configure the key

Under About, enter a Key name and an optional short description. Under Who can use this key?, choose All teams or Specific user:
  • For All teams, the key is an organization key. You are the key owner.
  • For Specific user, choose the user who owns the key.
Under Limits, set Expiration (for example, No expiration or a preset duration). Under Permissions, turn on the capabilities this key needs, such as Models for chat completions.
4

Generate and copy your API key

Select Generate. When the key appears, copy the full value and store it in a secure place. Acknowledge that you have copied the key before you leave the page. You can’t view or reveal the full key again after that.
Copy and store the key as soon as it’s shown. After you leave this step, the full value is no longer available.
Store the API key in a secure location, such as a .env file.
You can now make calls to the Writer API using this API key as the Bearer token in the header:
Learn more about creating and managing API keys in the API keys guide.

Make your first API call

Below is an example of an API call to the chat completion endpoint. It completes a single-turn chat completion, where the user provides a message and the AI assistant generates a response. The request is non-streaming and waits until the response is complete before returning.
The response is a JSON object with a choices array. The message.content field of the first choice contains the generated text. The message.role field indicates that the message is an AI assistant message.
In a streaming response, the structure of the response is similar. However, the content of the streamed response is returned in a choices[0].delta.content field, rather than the choices[0].message.content field. Learn more about streaming responses in the chat completion guide.
You can customize your request to the chat completion endpoint by adding or updating parameters to the request body. Learn more about the different parameters in the chat completion endpoint API reference.

Next steps

Now that you’ve made your first API call, learn how to use the Writer SDKs to make calls to the Writer API in your applications. Or, learn more about building with the chat completion endpoint: