cURL
curl --location --request POST https://api.writer.com/v1/completions \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data-raw '{"model":"palmyra-x5","prompt":"Write me a short SEO article about camping gear","max_tokens":150,"temperature":0.7,"top_p":0.9,"stop":["."],"best_of":1,"random_seed":42,"stream":false}'import os
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
completion = client.completions.create(
model="palmyra-x5",
prompt="Write me a short SEO article about camping gear",
)
print(completion.choices)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 completion = await client.completions.create({
model: 'palmyra-x5',
prompt: 'Write me a short SEO article about camping gear',
});
console.log(completion.choices);
}
main();{
"choices": [
{
"text": "Sure! Here's a search engine optimized article about...",
"log_probs": null
}
],
"model": "palmyra-x5"
}Completions API
Text generation
Generate text completions using the specified model and prompt. This endpoint is useful for text generation tasks that don’t require conversational context.
POST
/
v1
/
completions
cURL
curl --location --request POST https://api.writer.com/v1/completions \
--header "Authorization: Bearer <token>" \
--header "Content-Type: application/json" \
--data-raw '{"model":"palmyra-x5","prompt":"Write me a short SEO article about camping gear","max_tokens":150,"temperature":0.7,"top_p":0.9,"stop":["."],"best_of":1,"random_seed":42,"stream":false}'import os
from writerai import Writer
client = Writer(
# This is the default and can be omitted
api_key=os.environ.get("WRITER_API_KEY"),
)
completion = client.completions.create(
model="palmyra-x5",
prompt="Write me a short SEO article about camping gear",
)
print(completion.choices)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 completion = await client.completions.create({
model: 'palmyra-x5',
prompt: 'Write me a short SEO article about camping gear',
});
console.log(completion.choices);
}
main();{
"choices": [
{
"text": "Sure! Here's a search engine optimized article about...",
"log_probs": null
}
],
"model": "palmyra-x5"
}Deprecation notice: Palmyra X4 (
palmyra-x4) and Palmyra X5 (palmyra-x5) will be deprecated on December 14, 2026.Migration path: Use Palmyra X6 (palmyra-x6) instead. Palmyra X6 has a 1M token context window (Palmyra X4 is 128k). See pricing for cost details and the deprecation policy for more information.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.
Body
application/json
The ID of the model to use for generating text. This can be a Palmyra model such as palmyra-x5 or palmyra-x4, or the ID of an external model configured for your organization.
Response
Successful response
Was this page helpful?