Chat completion - Writer AI Studio
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
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"}]}'
import os
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
chat = client.chat.chat(
messages=[{
"content": "Write a memo summarizing this earnings report.",
"role": "user",
}],
model="palmyra-x5",
)
print(chat.id)
import Writer from 'writer-sdk';
const client = new Writer({
apiKey: process.env['WRITER_API_KEY'], // This is the default and can be omitted
});
async function main() {
const chat = await client.chat.chat({
messages: [{ content: 'Write a memo summarizing this earnings report.', role: 'user' }],
model: 'palmyra-x5',
});
console.log(chat.id);
}
main();
{
"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,
"web_search_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"
}
Authorization
Authorization header string format:
Bearer <token>where<token>is your Writer API key.
Body
- model: Required ID of the model to use.
- messages: Required array of message objects forming the conversation history.
- Minimum array length:
1.
- Minimum array length:
- max_tokens: Optional, max number of tokens in the response.
- temperature: Optional, default is 1, sets creativity level.
- top_p: Optional threshold for nucleus sampling.
- n: Optional specifies the number of completions to generate.
- stop: Optional token(s) to stop response generation.
- logprobs: Optional, default false, returns log probabilities.
- stream: Optional, default false, streams responses incrementally.
- tools: Optional array of tool definitions accessible by the model.