Powered by Claude · $0.05 per call

Prompt Optimizer API

Your prompt, plus your goal. Back comes a better prompt with a full explanation of every change and why it improves output quality.

The problem it solves

Most prompts in production agents are the first draft. They work "well enough," never get revisited, and silently underperform for months. Prompt engineering is a craft — but you don't always have time to do it from scratch for every LLM call.

This API applies established prompt engineering principles automatically, with explanations so you understand what changed.

How it works

Request

POST /api/tools/prompt-optimizer

{
  "prompt": "Summarize this document",
  "goal": "Extract key decisions and action items for a project manager"
}

Response

{
  "optimizedPrompt": "You are a project management assistant. Review the following document and produce a structured summary that includes:\n(1) Key decisions made, with context\n(2) Action items with owner and deadline if mentioned\n(3) Open questions requiring follow-up\n\nFormat your response as a bulleted list under each section.",

  "changes": [
    "Added a clear role/persona to orient the model",
    "Made the output format explicit with three specific sections",
    "Specified structured formatting to ensure consistent, parseable output"
  ],

  "estimatedImprovement": "High — original prompt was ambiguous about scope and format"
}

The changes field is the best part

It's not just a better prompt — it's an explanation of which prompt engineering principles were applied and why. Over time, this teaches you to write better prompts natively.

Principle applied

Role assignment

"You are a [expert]..." orients the model and improves output register

Principle applied

Explicit output format

Structured format requirements make output consistent and parseable

Principle applied

Scope definition

Explicit inclusion/exclusion removes ambiguity and reduces hallucination

TypeScript SDK

import { AgentToolbelt } from "agent-toolbelt";

const toolbelt = new AgentToolbelt({ apiKey: process.env.TOOLBELT_KEY });

// Optimize before deploying to production
const { optimizedPrompt, changes, estimatedImprovement } =
  await toolbelt.promptOptimizer({
    prompt: draftPrompt,
    goal: "Extract structured contact info from business card text",
  });

console.log("Changes made:", changes);
// → Use optimizedPrompt in your agent

Pricing

$0.05 per call

Powered by Claude — the cheapest prompt engineering review you can get

Get API Key →

More tools

Part of Agent Toolbelt — 14 focused API tools for AI developers