Documentation

Learn how to use PromptPDF effectively

Generate Document API

The Generate Document API endpoint allows you to create documents using AI models and templates programmatically.

Endpoint

POST https://api.promptpdf.com/v1/generate

Authentication

This endpoint requires authentication. See the Authentication page for details.

Request Parameters

The request body should be a JSON object with the following parameters:

ParameterTypeRequiredDescription
promptstringYesThe text prompt describing what you want in the document
templatestringNoThe template ID to use (default: "blank")
modelTypestringNoThe AI model to use (default: "qwen")
formatstringNoThe output format: "pdf", "doc", "csv", or "markdown" (default: "pdf")
existingContentstringNoExisting content to refine (for document refinement)
webhookbooleanNoWhether to use webhooks for notification (default: false)
webhookUrlstringNoCustom webhook URL (overrides the default webhook URL in your settings)

Available Templates

The following template IDs are available:

  • blank: Blank document with minimal formatting
  • formal-letter: Standard formal letter format
  • formal-complaint: Letter for formal complaints or requests
  • job-application: Letter for applying to jobs
  • resignation: Letter for resigning from a position
  • academic-paper: Format for academic research papers
  • resume: Professional resume or curriculum vitae
  • code-documentation: Documentation for software projects
  • book-chapter: Format for book chapters
  • faq: Frequently asked questions format
  • presentation: Script for presentations or speeches
  • data-report: Report with data analysis
  • legal-document: Format for legal documents

Available Models

The following model IDs are available:

  • qwen: Qwen QwQ 32B
  • deepseek: DeepSeek R1 Zero
  • olympiccoder32b: OlympicCoder 32B
  • olympiccoder7b: OlympicCoder 7B
  • gemma3-27b: Gemma 3 27B
  • gemma3-4b: Gemma 3 4B
  • gemma3-1b: Gemma 3 1B
  • dolphin-mistral: Dolphin Mistral 24B
  • mistral-small: Mistral Small 24B
  • llama-nemotron: Llama 3.1 Nemotron 70B
  • openai: OpenAI GPT-4o

Example Request

// 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 purchased on March 10, 2025. The product was a laptop that stopped working after 2 days.',
    template: 'formal-complaint',
    modelType: 'qwen',
    format: 'pdf'
  })
});

const data = await response.json();

Response

The response is a JSON object with the following structure:

Success Response

{
  "success": true,
  "content": "123 Maple Street\nAnytown, CA 91234\n\nMarch 19, 2025\n\nCustomer Service Department\nTech Solutions Inc.\n456 Oak Avenue\nAnytown, CA 91235\n\n**Subject: Formal Complaint Regarding Defective Laptop**\n\nDear Customer Service Manager:\n\nI am writing to file a formal complaint regarding a defective laptop I purchased from your store on March 10, 2025....",
  "reasoning": null // Only present for certain models like deepseek
}

Error Response

{
  "success": false,
  "error": {
    "code": "invalid_parameters",
    "message": "Invalid template specified"
  }
}

Webhook Notifications

For long-running operations, you can use webhooks to receive notifications when document generation is complete:

  1. Set webhook: true in your request
  2. Optionally specify a custom webhookUrl
  3. The API will return a job ID immediately
  4. When processing is complete, a POST request will be sent to your webhook URL

Webhook Request Format

{
  "jobId": "job_123456789",
  "status": "completed",
  "content": "Generated document content...",
  "timestamp": "2025-03-19T12:34:56Z"
}

Error Codes

The API may return the following error codes:

CodeDescription
unauthorizedInvalid API key or insufficient permissions
invalid_parametersOne or more parameters are invalid
rate_limit_exceededYou have exceeded your rate limit
model_unavailableThe requested AI model is currently unavailable
generation_failedDocument generation failed
server_errorInternal server error

Next Steps

After generating a document, you may want to: