Quickstart
This guide helps you make your first API calls to the Writer API. You’ll create an API app in AI Studio, get an API key, and begin making API calls to generate text using the chat completion endpoint.
Get an API key
Before you can make API calls, you need to create an API app in AI Studio and get an API key.
- From the AI Studio home page, click Build an app.
- Select API as the app type.
- Click on the title to edit it and provide a short description of your app to help you keep track of what it does.
- Under API keys there is a key named
Production
. Click Reveal key to view the key.
.env
file to store the key.You can now make calls to the Writer API using this API key as the Bearer
token in the header:
Learn more about 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.
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:
- Learn how to build a multi-turn, conversational AI app using the chat completion guide
- See the full chat completion endpoint API reference
Was this page helpful?