Prompt Optimizer API

Category: developer

Improve and optimize AI prompts for better results. Uses GPT to rewrite prompts with different optimization styles.

Endpoint

POST https://anythingtext.com/api/tools/promptopt
API Key Required Content-Type: application/json

API Key

This API requires an API key. No login or OAuth is needed. Generate your key from the API Keys section in your dashboard settings.

Include the X-API-Key header in all API requests:

X-API-Key: atk_your_api_key_here

Rate Limiting

API requests are limited to 60 requests per minute per user. If you exceed this limit, the API returns a 429 Too Many Requests response.

Every response includes rate limit headers:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 42

When rate limited, the response body contains:

{ "error": "Rate limit exceeded. Maximum 60 requests per minute.", "retryAfter": 42, "limit": 60 }

Request Parameters

Name Type Required Description
prompt string Required The prompt to optimize
Example: Write me a blog post about machine learning. Make it good.
style string Optional Optimization style: general, concise, detailed, creative, technical
Example: general

Response

Content-Type: application/json

Returns JSON with the optimized prompt and a list of changes made.

{"result": "{\"optimized\": \"...\", \"changes\": [...]}"}

Error Responses

StatusDescriptionBody
401 Not authenticated {"error": "Please log in..."}
400 Bad request / Missing required params {"error": "... is required"}
500 Internal server error {"error": "Failed to ..."}

cURL Example

curl -X POST https://anythingtext.com/api/tools/promptopt \
  -H 'Content-Type: application/json' \
  -d '{"prompt": "Write me a blog post about ML", "style": "detailed"}'

Code Samples

const response = await fetch('/api/tools/promptopt', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ prompt: 'Write a blog post about ML', style: 'detailed' })
});
const data = await response.json();
const parsed = JSON.parse(data.result);
console.log('Optimized:', parsed.optimized);
console.log('Changes:', parsed.changes);
import requests, json

response = requests.post('https://anythingtext.com/api/tools/promptopt',
    json={'prompt': 'Write a blog post about ML', 'style': 'detailed'})
data = response.json()
parsed = json.loads(data['result'])
print('Optimized:', parsed['optimized'])
print('Changes:', parsed['changes'])