GET
/
prompt
/
optimize
import PiClient from 'withpi';

const client = new PiClient({
  apiKey: process.env['WITHPI_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const promptOptimizationStatuses = await client.prompt.optimize.list();

  console.log(promptOptimizationStatuses);
}

main();
[
  {
    "detailed_status": [
      "Downloading model",
      "Tuning prompt"
    ],
    "job_id": "1234abcd",
    "optimized_prompt_messages": [
      {
        "content": "Write a great story around the given topic.",
        "role": "system"
      },
      {
        "content": "{{ input }}",
        "role": "user"
      }
    ],
    "state": "RUNNING"
  }
]

Authorizations

x-api-key
string
header
required

Query Parameters

state
enum<string> | null

Filter jobs by state

Available options:
QUEUED,
RUNNING,
DONE,
ERROR,
CANCELLED

Response

200
application/json
Successful Response
detailed_status
string[]
required

Detailed status of the job

Example:
["Downloading model", "Tuning prompt"]
job_id
string
required

The job id

Example:

"1234abcd"

state
enum<string>
required

Current state of the job

Available options:
QUEUED,
RUNNING,
DONE,
ERROR,
CANCELLED
optimized_prompt_messages
object[]

The optimized prompt messages in the OpenAI message format with the jinja {{ input }} variable for the next user prompt

Example:
[
  {
    "content": "Write a great story around the given topic.",
    "role": "system"
  },
  { "content": "{{ input }}", "role": "user" }
]