Skip to main content
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-x-003-instruct","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}'
{
  "choices": [
    {
      "text": "Sure! Here's a search engine optimized article about...",
      "log_probs": null
    }
  ],
  "model": "palmyra-x-003-instruct"
}
Deprecation notice: The following models are deprecated and will be removed on July 13, 2026: palmyra-x-003-instruct, palmyra-vision, palmyra-med, palmyra-fin, and palmyra-creative.Migration path: Use palmyra-x5 as the replacement for all deprecated models. Palmyra X5 supports a 1M-token context window and covers general-purpose, financial, medical, and creative use cases. For vision workloads, use chat with images with Palmyra X5 instead of palmyra-vision. See the deprecation policy for more information.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your Writer API key.

Body

application/json
model
string
required

The ID of the model to use for generating text. Supports palmyra-x5, palmyra-x4, palmyra-fin, palmyra-med, palmyra-creative, and palmyra-x-003-instruct.

prompt
string
required

The input text that the model will process to generate a response.

max_tokens
integer<int64>

The maximum number of tokens that the model can generate in the response.

temperature
number<double>

Controls the randomness of the model's outputs. Higher values lead to more random outputs, while lower values make the model more deterministic.

top_p
number<double>

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.

stop

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.

best_of
integer<int32>

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.

random_seed
integer<int32>

A seed used to initialize the random number generator for the model, ensuring reproducibility of the output when the same inputs are provided.

stream
boolean

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

choices
object[]
required

A list of choices generated by the model, each containing the text of the completion and associated metadata such as log probabilities.

Minimum array length: 1
model
string

The identifier of the model that was used to generate the responses in the 'choices' array.