Primitives.org.ai

write

Generate formatted text content

Generate text content with optional formatting and structure.

Import

import { write } from 'ai-functions'

Syntax

write`prompt with ${values}`
write(type: string, context: object)

Examples

// Tagged template
const email = await write`professional email to ${recipient} about ${subject}`
const bio = await write`twitter bio for ${{ name, profession, interests }}`

// With options
const post = await write('blog post', {
  topic: 'TypeScript Best Practices',
  length: 'medium',
  tone: 'casual',
})

// Complex context
const article = await write`
  technical blog post about ${topic}
  ${{ tone: 'friendly but authoritative', length: '1500 words' }}
`({ model: 'gemini-3-flash' })

Content Types

// Articles
const post = await write`blog post about ${topic}`
const article = await write`technical article on ${subject}`

// Communications
const email = await write`professional email about ${matter}`
const message = await write`slack message announcing ${news}`

// Social
const tweet = await write`tweet about ${topic}`
const bio = await write`linkedin bio for ${person}`

// Marketing
const copy = await write`landing page copy for ${product}`
const tagline = await write`tagline for ${brand}`

Options

OptionDescription
length'short' | 'medium' | 'long'
tone'formal' | 'casual' | 'technical'
audienceTarget audience description
formatOutput format (markdown, plain, etc.)
Was this page helpful?

On this page