Get an API key
Before you can make API calls, you need to create an API key in AI Studio.1
Create an API agent
From the AI Studio home page, navigate to the API Keys page on the left sidebar.

2
Create an API agent
Click the Create API agent button in the top right corner of the page.

3
Configure the agent
Click the title of the agent to edit it and provide a short description to help you keep track of what it does.

4
Get your API key
Under API keys there is a key named You can generate a new key that’s scoped to the same capabilities as the original key any time from the API agent’s page.
Production
. Click the eye icon to view the key or Copy to copy the key.You cannot view the API key value after creating it, so make sure to copy it and keep it secure.
Store the API key in a secure location, such as a
.env
file.Bearer
token in the header:
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.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.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:- Learn how to build a multi-turn, conversational AI app using the chat completion guide
- See the full chat completion endpoint API reference