Promptly API & SDK

Integrate AI prompt optimization into any website with just a few lines of code.

How it works

1

Create an API key

Sign up and generate your key in Settings > API.

2

Add the SDK

Copy the HTML snippet into your site.

3

Users optimize

The Promptly icon appears and transforms queries into detailed prompts.

Quick Start

HTML

<script src="https://aipromptly.org/sdk/promptly-sdk.js"></script>
<script>
  Promptly.init({
    apiKey: 'pk_your_api_key',
    theme: 'light',       // 'light' or 'dark'
    position: 'right',    // 'right' or 'left'
    selector: 'textarea', // CSS selector (optional)
    onSuccess: (prompt) => console.log('Generated:', prompt),
    onError: (err) => console.error('Error:', err)
  });
</script>

API Reference

POST/functions/v1/promptly-api

Headers

x-api-key: pk_your_api_key
Content-Type: application/json

Request Body

{
  "input": "Write a blog post about AI trends"
}

Response

{
  "prompt": "As an expert technology writer...",
  "credits_remaining": 95
}

Error Codes

401Invalid or missing API key

403Domain not authorized

429Monthly limit reached

400Missing or too long input (max 2000 chars)

cURL

curl -X POST https://svgtialpkqtaawfyeuic.supabase.co/functions/v1/promptly-api \
  -H "Content-Type: application/json" \
  -H "x-api-key: pk_your_api_key" \
  -d '{"input": "Write a blog post about AI trends"}'

Security

  • Keys prefixed with pk_ for identification
  • Origin domain validation (optional)
  • Configurable monthly limit per key
  • No user data stored (stateless)