Prompt Optimizer API documentation

Optimize prompts programmatically and integrate Promptdoo into your workflows.
Back

Prompt Optimizer API


This page explains how to optimize prompts programmatically using the Promptdoo API.

Overview


Use the Prompt Optimizer API if you want to:

  • optimize prompts from your own app
  • run batch optimization
  • integrate prompt optimization into workflows

Notes:

  • API calls consume credits depending on the selected model.
  • Authentication is typically done via an API token (Bearer).

Authentication


Use an API token as Bearer token:

Authorization: Bearer YOUR_TOKEN_HERE

Endpoint


  • URL: POST https://promptdoo.com/api/v1/prompt-optimizer
  • Content-Type: application/json

Request body (example)


{
  "prompt": "Write a short product description for a coffee grinder",
  "use_case": "marketing",
  "tone": "professional",
  "verbosity": "short",
  "model_id": 12,
  "options": {
    "output_format": "bullet_list"
  }
}

Response (example)


{
  "data": {
    "optimized_prompt": "...",
    "model_id": 12,
    "credits_spent": 3
  }
}

Best practices


  • Keep the input prompt short and specific.
  • Provide the desired output format.
  • Iterate: optimize → test → refine.
  • Store your API token securely.

Common errors


  • 401 Unauthorized: missing/invalid token
  • 402 Payment Required: not enough credits
  • 429 Too Many Requests: rate limit exceeded