v42

latestOpenAPI 3.0.3raw.githubusercontent.com2026-07-2129120150.2 KB
Generation 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

Request body

modelstring 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.

promptstring required

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

max_tokensinteger

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

temperaturenumber 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_pnumber 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.

best_ofinteger

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_seedinteger

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

streamboolean

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.

Example request

{
  "model": "palmyra-x-003-instruct",
  "prompt": "Write me an SEO article about...",
  "max_tokens": 150,
  "temperature": 0.7,
  "top_p": 0.9,
  "stop": [
    "."
  ],
  "best_of": 1,
  "random_seed": 42,
  "stream": false
}

Response

Successful response

modelstring

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

Example response

{
  "choices": [
    {
      "text": "Sure! Here's a search engine optimized article about...",
      "log_probs": null
    }
  ],
  "model": "palmyra-x-003-instruct"
}