Examples

Explore practical examples to understand how to use INK effectively in various scenarios.

Content Generation Examples

Marketing Copy

Generate compelling marketing copy for your products:

const response = await ink.generate({
  prompt: `Create marketing copy for a new eco-friendly water bottle.
    Target audience: health-conscious millennials.
    Tone: casual but professional.
    Include: key features, benefits, and a call-to-action.`,
  template: 'marketing-copy'
})

Executive Summary

Create a professional executive summary:

const response = await ink.generate({
  prompt: `Write an executive summary for Q4 2024 performance.
    Key metrics: 25% revenue growth, 40% new customer acquisition.
    Challenges: supply chain delays, increased competition.
    Outlook: optimistic with expansion plans.`,
  template: 'executive-summary'
})

Strategic Brief Examples

Market Entry Strategy

const response = await ink.generate({
  prompt: `Develop a market entry strategy for a SaaS product
    entering the European market.
    Focus on: Germany and France.
    Considerations: GDPR compliance, localization, pricing.`,
  template: 'strategic-brief'
})

Competitive Analysis

const response = await ink.generate({
  prompt: `Analyze the competitive landscape for sustainable fashion.
    Include: top 5 competitors, market positioning, opportunities.`,
  template: 'market-analysis'
})

Integration Examples

Webhook Handler

app.post('/webhook/ink', async (req, res) => {
  const { event, data } = req.body

  switch (event) {
    case 'generation.completed':
      await saveContent(data.content)
      break
    case 'export.ready':
      await notifyUser(data.exportUrl)
      break
  }

  res.status(200).json({ received: true })
})

Batch Processing

const prompts = [
  'Write a product description for...',
  'Create a social media post about...',
  'Draft an email announcing...',
]

const results = await Promise.all(
  prompts.map(prompt =>
    ink.generate({ prompt, template: 'general' })
  )
)

Error Handling

try {
  const response = await ink.generate({
    prompt: 'Your prompt here',
    template: 'general'
  })
  console.log(response.content)
} catch (error) {
  if (error.code === 'RATE_LIMIT_EXCEEDED') {
    console.log('Rate limited, retrying in 60s...')
  } else if (error.code === 'INVALID_TEMPLATE') {
    console.log('Template not found')
  } else {
    console.error('Unexpected error:', error.message)
  }
}

Next Steps