Skip to Content
Functions

Functions.do Composable Units of Work

Predictable AI results through elegant, type-safe functions

Setup

Install the functions.do package:

npm i functions.do

Then get your API key and set it in an environment variable:

DO_API_KEY=sk_do_*****************************

Usage

Generate Objects without a Schema

import { ai } from 'functions.do' const brand = await ai.storyBrand({ idea: 'Auto Loan Underwriting Services-as-Software' })

Generate Text

const post = await ai`write a blog post introducing ${idea} and ${brand}`

Generate Lists

const titles = await ai.list`${count} possible blog post titles related to ${idea}` titles.forEach((title) => ai`write a blog post starting with "# ${title}"`)

Type-safe Schema

import { AI } from 'functions.do' const ai = AI({ leanCanvas: { productName: 'name of the product or service', problem: ['top 3 problems the product solves'], solution: ['top 3 solutions the product offers'], uniqueValueProposition: 'clear message that states the benefit of your product', unfairAdvantage: 'something that cannot be easily copied or bought', customerSegments: ['list of target customer segments'], keyMetrics: ['list of key numbers that tell you how your business is doing'], channels: ['path to acquire customers'], costStructure: ['list of operational costs'], revenueStreams: ['list of revenue sources'], }, }) const businessModel = await ai.leanCanvas({ idea: 'Auto Lending Services-as-Software' })
Last updated on