Primitives.org.ai

ai-functions

Call AI like you'd talk to a colleague

npm install ai-functions

Say what you need. Get what you asked for.

import { ai, list, is } from 'ai-functions'

// Ask questions
const qualified = is`${lead} a good fit for enterprise?`

// Generate lists
const ideas = list`content topics for ${persona}`

// Get structured data through destructuring
const { summary, nextSteps } = ai`analyze ${salesCall}`

Promise Pipelining

Chain without await:

const { score, reason } = ai`qualify ${lead}`
const email = ai`follow-up based on: ${reason}`

if (await score > 80) {
  await send(await email)
}

Batch Processing

Process arrays in one call:

const qualified = await list`leads`.map(lead => ({
  lead,
  fit: is`${lead} matches ${icp}?`,
  action: ai`next step for ${lead}`,
}))

Exports

ExportDescription
aiFlexible generation
listGenerate arrays
listsNamed lists
isBoolean questions
writeLong-form content
summarizeCondense text
extractStructured extraction
codeCode generation
decidePick best option
researchWeb research
askHuman input
approveHuman approval
Was this page helpful?

On this page