API Reference

Use the PromptGen API to generate expert AI prompts programmatically from any language or platform.

Base URL: https://getpromptgen.com/api/v1
All requests must include your API key in the Authorization header.

Authentication

All API requests are authenticated using an API key passed as a Bearer token.

Authorization: Bearer sb_live_YOUR_API_KEY

Generate your API key in Settings → Developer. Keys start with sb_live_ and are shown only once at creation.

Rate Limits

PlanCalls / dayMax keys
Free105
Pro5005

When you exceed the limit, the API returns 429 Too Many Requests. Limits reset at midnight UTC.

Each response includes calls_remaining_today so you can track usage programmatically.

Generate a Prompt

POST /api/v1/generate

Generates a structured, expert-quality prompt for any task.

Request Body

FieldTypeDescription
taskrequiredstringWhat you want the prompt to accomplish
domainstringDomain hint: auto, software, business, creative, education, research, data. Default: auto
techniquestringPrompting technique: auto, chain_of_thought, few_shot, role_play, step_by_step. Default: auto
target_aistringModel to optimise for: general, claude, gpt4, gemini. Default: general
providerstringWhich LLM generates the prompt: anthropic, openai, gemini. Default: anthropic
contextstringOptional extra context for the prompt

Response

FieldTypeDescription
promptstringThe generated, ready-to-use prompt
quality_scorefloatQuality score 1–10
quality_reasoningstringOne-line explanation of the score
domainstringDomain used
techniquestringTechnique used
model_usedstringExact model ID that generated the prompt
providerstringProvider used
latency_msintegerGeneration time in milliseconds
calls_remaining_todayintegerRemaining API calls for today

Example Request

curl -X POST https://getpromptgen.com/api/v1/generate \
  -H "Authorization: Bearer sb_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "Write a blog post about the future of AI",
    "domain": "creative",
    "provider": "anthropic"
  }'

Example Response

{
  "prompt": "You are an expert technology writer with 10 years...",
  "quality_score": 9.2,
  "quality_reasoning": "Clear persona, structured output, and specific constraints.",
  "domain": "creative",
  "technique": "chain_of_thought",
  "model_used": "claude-sonnet-4-6",
  "provider": "anthropic",
  "latency_ms": 1842,
  "calls_remaining_today": 9
}

Get API Identity

GET /api/v1/me

Returns information about the API key and its owner. Useful for verifying a key works.

curl https://getpromptgen.com/api/v1/me \
  -H "Authorization: Bearer sb_live_YOUR_KEY"
{
  "user_email": "you@example.com",
  "plan": "free",
  "key_prefix": "sb_live_a8f3",
  "calls_today": 1,
  "daily_limit": 10,
  "calls_remaining": 9
}

Error Codes

StatusMeaning
400Bad request — missing or invalid fields
401Invalid or missing API key
403Account inactive or no access
429Daily rate limit exceeded
502Upstream LLM provider error

All errors return JSON: {"detail": "Human-readable message"}

Code Examples

Python

import requests

resp = requests.post(
    "https://getpromptgen.com/api/v1/generate",
    headers={"Authorization": "Bearer sb_live_YOUR_KEY"},
    json={"task": "Summarise this document", "domain": "business"}
)
data = resp.json()
print(data["prompt"])

JavaScript / Node

const res = await fetch("https://getpromptgen.com/api/v1/generate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sb_live_YOUR_KEY",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ task: "Write unit tests for my auth module" })
});
const { prompt } = await res.json();
console.log(prompt);

PHP

$ch = curl_init("https://getpromptgen.com/api/v1/generate");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer sb_live_YOUR_KEY",
    "Content-Type: application/json"
  ],
  CURLOPT_POSTFIELDS => json_encode(["task" => "Create a marketing email"])
]);
$data = json_decode(curl_exec($ch), true);
echo $data["prompt"];