API Reference
PromptPDF offers a powerful API that allows you to integrate AI-powered document generation into your own applications. This reference provides technical details for using the API.
API Overview
The PromptPDF API allows you to:
- Generate documents using AI models
- Convert documents to various formats (PDF, DOC, etc.)
- Access templates and models programmatically
- Integrate document generation into your workflows
Base URL
https://api.promptpdf.com/v1
Authentication
All API requests require authentication using an API key. See the Authentication page for details.
API Endpoints
Generate Document
Generate a document using AI models and templates.
POST /generate
See Generate Document for details.
PDF Download
Convert document content to PDF format.
POST /pdf
See PDF Download for details.
List Templates
Get a list of available document templates.
GET /templates
Returns a JSON array of available templates with their IDs and descriptions.
List Models
Get a list of available AI models.
GET /models
Returns a JSON array of available AI models with their IDs and capabilities.
Response Format
All API responses are in JSON format unless otherwise specified (e.g., PDF downloads return binary data).
Success Response
{
"success": true,
"data": {
// Response data varies by endpoint
}
}Error Response
{
"success": false,
"error": {
"code": "error_code",
"message": "Human-readable error message",
"details": {} // Optional additional error details
}
}Rate Limits
API requests are subject to rate limiting:
- Free tier: 100 requests per day
- Basic tier: 1,000 requests per day
- Professional tier: 10,000 requests per day
- Enterprise tier: Custom limits
API SDKs
PromptPDF provides official SDKs for popular programming languages:
- JavaScript/TypeScript (Node.js)
- Python
- PHP
- Ruby
- Java
- Go
Example: Generate Document
Here's a simple example of generating a document using the API with JavaScript:
// Using fetch API
const response = await fetch('https://api.promptpdf.com/v1/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
},
body: JSON.stringify({
prompt: 'Write a formal letter requesting a refund for a defective product',
template: 'formal-letter',
modelType: 'qwen',
format: 'pdf'
})
});
const data = await response.json();
console.log(data.content); // Generated document contentWebhooks
For long-running operations, PromptPDF supports webhooks to notify your application when processing is complete:
- Register a webhook URL in your API settings
- Include
webhook: truein your API requests - Receive a POST request to your webhook URL when processing completes
Next Steps
Explore detailed documentation for specific API endpoints: