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"
}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.
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"
}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
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.
The input text that the model will process to generate a response.
The maximum number of tokens that the model can generate in the response.
Controls the randomness of the model's outputs. Higher values lead to more random outputs, while lower values make the model more deterministic.
Used to control the nucleus sampling, where only the most probable tokens with a cumulative probability of top_p are considered for sampling, providing a way to fine-tune the randomness of predictions.
Specifies stopping conditions for the model's output generation. This can be an array of strings or a single string that the model will look for as a signal to stop generating further tokens.
Specifies the number of completions to generate and return the best one. Useful for generating multiple outputs and choosing the best based on some criteria.
A seed used to initialize the random number generator for the model, ensuring reproducibility of the output when the same inputs are provided.
Determines whether the model's output should be streamed. If true, the output is generated and sent incrementally, which can be useful for real-time applications.
Response
Successful response
A list of choices generated by the model, each containing the text of the completion and associated metadata such as log probabilities.
1Show child attributes
Show child attributes
The identifier of the model that was used to generate the responses in the 'choices' array.
Was this page helpful?