Production
. Click Reveal key to view the key..env
file to store the key.Bearer
token in the header:
Authorization: Bearer <api-key>
curl --location 'https://api.writer.com/v1/chat' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <your-api-key>' \
--data '{
"model": "palmyra-x5",
"messages": [
{
"role": "user",
"content": "Write a one sentence product description for a cozy, stylish sweater suitable for both casual and formal occasions"
}
]
}'
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.
{
"id": "78766762-bd30-4a42-bb2b-e0b35c608217",
"object": "chat.completion",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"content": "This versatile, cozy sweater blends warmth and elegance with its soft knit and refined design, making it perfect for both casual days and formal evenings.",
"role": "assistant",
"tool_calls": null,
"graph_data": {
"sources": null,
"status": null,
"subqueries": null
},
"llm_data": null,
"image_data": null,
"refusal": null
},
"logprobs": null
}
],
"created": 1740711212,
"model": "palmyra-x5",
"usage": {
"prompt_tokens": 50,
"total_tokens": 79,
"completion_tokens": 29,
"prompt_token_details": null,
"completion_tokens_details": null
},
"system_fingerprint": "v1",
"service_tier": null
}
choices[0].delta.content
field, rather than the choices[0].message.content
field. Learn more about streaming responses in the chat completion guide.Was this page helpful?