Forma PDF

Generate PDF templates with OpenAI or Claude

By WVSTECH · Reviewed November 23, 2026 · Examples target SDK 0.4.0

Forma PDF supports optional AI template creation through an AI gateway. A user describes a document; the provider proposes a layout and values; the SDK validates the response. The user should review the fields before applying the template.

Request a template with fictional sample data

const result = await generateAITemplate({
  provider: 'openai',
  locale: 'en',
  prompt: 'Create an A4 quotation with customer name and a services table.',
  sampleValues: {
    client: { name: 'Northstar Co.' },
    items: [{ description: 'Design', price: '$800.00' }]
  }
}, { endpoint: '/api/ai/templates', apiKey: userProvidedKey })

showTemplateReview(result.layout, result.values, result.contract)

showTemplateReview is your own review UI. After confirmation, use editor.setDocument(result.layout, result.values). Use provider anthropic for Claude with a gateway configured to support it. Do not blindly apply an unreviewed model response.

Does every PDF require AI?

No. Once the template is saved, generatePDF(layout, values) uses the PDF engine without an LLM request. Provider charges apply to optional AI calls, not to ordinary local PDF generation.

Where does the key go?

The requesting app sends a personal key through the configured gateway to the selected provider. Shared business credentials must stay on your backend. Review your gateway authentication, logging and retention before exposing the feature. Follow the AI implementation manuals for the full contract.

Continue building

Try the visual editor View the SDK license