Launch offer: service fee 10% 4% until 31 Dec, just enough to cover card processing. See pricing

Developers

Vercel AI SDK

Give your own agent Yap Factory tools: search creators, run campaigns, keep deals moving and schedule posts. @yapfactory/ai-sdk turns every API operation into an AI SDK tool.

View as Markdown

Building inside ChatGPT or Claude instead? Use the MCP server: no code.

Install

pnpm add @yapfactory/ai-sdk ai

Works with AI SDK 5, 6 and 7, in Node 18 or later and on edge runtimes.

Get an API key

In Yap Factory, open Settings → AI agents → Make an API key, then set it as YAPFACTORY_API_KEY. The tools act as you: a brand key gets the brand tools, a creator key the creator tools.

.env
YAPFACTORY_API_KEY=yf_live_...

Acting for other people, each with their own account? Get each person's token with OAuth and pass it as apiKey.

Quick start

import { generateText, isStepCount } from 'ai';
import { yapfactoryTools } from '@yapfactory/ai-sdk';

const { text } = await generateText({
  model: 'anthropic/claude-sonnet-4.5',
  prompt: 'Find three UGC creators for my skincare campaign and say why each one fits.',
  tools: yapfactoryTools({ access: 'read' }),
  stopWhen: isStepCount(5),
});

console.log(text);

access: 'read' gives only the tools that change nothing, which suits a first try.

Ask before anything reaches people

Some tools tell other people straight away: publishing a campaign, inviting creators, messages, answering invites and scheduled posts. createYapFactory() returns a toolApproval map (AI SDK 7) that marks each of them user-approval, so the AI SDK stops and asks your user before they run. On AI SDK 5 or 6, use access: 'write', which leaves those tools out.

import { generateText, isStepCount } from 'ai';
import { createYapFactory } from '@yapfactory/ai-sdk';

const yapfactory = createYapFactory();

const result = await generateText({
  model: 'anthropic/claude-sonnet-4.5',
  prompt: 'Draft a UGC campaign for my app, then invite the three best-fitting creators.',
  tools: yapfactory.tools,
  toolApproval: yapfactory.toolApproval, // invites, publishing, messages and posts wait for a yes
  stopWhen: isStepCount(8),
});

// Calls that need a yes come back as tool-approval-request parts.
const waiting = result.steps.flatMap((s) => s.content).filter((p) => p.type === 'tool-approval-request');

No tool moves money. Starting a deal (the brand's card is charged) and approving a draft (the creator is paid) return a link to finish on yapfactory.com.

Options

OptionDefaultWhat it does
apiKeyYAPFACTORY_API_KEYAn API key (yf_live_…) or an OAuth access token.
access'all''read': only tools that change nothing. 'write': also your own drafts, briefs and scheduled posts. 'all': also tools that reach people and the payment links.
sideboth'brand' or 'creator': only that side's tools (shared tools stay).
onlyevery toolA list of tool names, such as ['searchCreators', 'getCreator'].
baseURLhttps://yapfactory.com/api/v1Another Yap Factory host, for testing.
headers, fetchnoneExtra headers, or your own fetch.

Results and errors

  • Each tool returns the API's JSON: { data }, and lists also carry nextCursor and hasMore. Money is { minor, currency, formatted }.
  • When the API refuses a call, the tool returns { error: { code, message, status, requestId } } instead of throwing, so the model can tell the person what happened. message is written for people. See errors.
  • Calls that change something send an Idempotency-Key made from the tool call's id, so a retried step never runs twice.
  • Rate limits are per key: 120 reads, 20 writes and 10 calls that reach people a minute.

The tools

One tool per API operation, named in camelCase. Each links to its reference page.

ToolForKind
getAccountEveryoneReads
listDealsEveryoneReads
getDealEveryoneReads
sendDealMessageEveryoneReaches people: asks first
searchCreatorsBrandsReads
getCreatorBrandsReads
listProductsBrandsReads
listCampaignsBrandsReads
getCampaignBrandsReads
createCampaignDraftBrandsYour own things
updateCampaignBriefBrandsYour own things
publishCampaignBrandsReaches people: asks first
setCampaignStatusBrandsReaches people: asks first
inviteCreatorsBrandsReaches people: asks first
passOnCreatorBrandsReaches people: asks first
requestRevisionBrandsReaches people: asks first
browseCampaignsCreatorsReads
viewCampaignBriefCreatorsReads
askToJoinCreatorsReaches people: asks first
respondToInviteCreatorsReaches people: asks first
listPostAccountsBrandsReads
getPostAccountBrandsReads
listPostableVideosBrandsReads
preparePostUploadBrandsYour own things
schedulePostBrandsReaches people: asks first
listPostsBrandsReads
updatePostBrandsYour own things
cancelPostBrandsYour own things
startDealBrandsReturns a link
approveDraftBrandsReturns a link

Source and support