General usage
Applications API
Completions API
Files API
Knowledge Graphs API
Vision API
Completions API
Chat completion
Generate a chat completion based on the provided messages. The response shown below is for non-streaming. To learn about streaming responses, see the chat completion guide.
POST
/
v1
/
chat
curl --location --request POST https://api.writer.com/v1/chat \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data-raw '{"model":"palmyra-x5","messages":[{"content":"Write a memo summarizing this earnings report.","role":"user"}]}'
{
"id": "57e4f58f-f7b1-41d8-be17-a6279c073aad",
"object": "chat.completion",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"content": "The earnings report shows...",
"role": "assistant",
"refusal": null,
"tool_calls": [],
"graph_data": {
"sources": [],
"status": "finished",
"subqueries": []
},
"llm_data": {
"prompt": "Write a memo summarizing this earnings report.",
"model": "palmyra-x5"
},
"translation_data": null
}
}
],
"created": 1715361795,
"model": "palmyra-x5",
"usage": {
"prompt_tokens": 40,
"total_tokens": 340,
"completion_tokens": 300,
"prompt_token_details": {
"cached_tokens": 0
},
"completion_token_details": {
"reasoning_tokens": 0
}
},
"system_fingerprint": "v1",
"service_tier": "standard"
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your Writer API key.
Body
application/json
Response
200
application/json
Successful response
The response is of type object
.
Was this page helpful?
curl --location --request POST https://api.writer.com/v1/chat \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data-raw '{"model":"palmyra-x5","messages":[{"content":"Write a memo summarizing this earnings report.","role":"user"}]}'
{
"id": "57e4f58f-f7b1-41d8-be17-a6279c073aad",
"object": "chat.completion",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"content": "The earnings report shows...",
"role": "assistant",
"refusal": null,
"tool_calls": [],
"graph_data": {
"sources": [],
"status": "finished",
"subqueries": []
},
"llm_data": {
"prompt": "Write a memo summarizing this earnings report.",
"model": "palmyra-x5"
},
"translation_data": null
}
}
],
"created": 1715361795,
"model": "palmyra-x5",
"usage": {
"prompt_tokens": 40,
"total_tokens": 340,
"completion_tokens": 300,
"prompt_token_details": {
"cached_tokens": 0
},
"completion_token_details": {
"reasoning_tokens": 0
}
},
"system_fingerprint": "v1",
"service_tier": "standard"
}