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.
Building inside ChatGPT or Claude instead? Use the MCP server: no code.
Install
pnpm add @yapfactory/ai-sdk aiWorks 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.
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
| Option | Default | What it does |
|---|---|---|
apiKey | YAPFACTORY_API_KEY | An 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. |
side | both | 'brand' or 'creator': only that side's tools (shared tools stay). |
only | every tool | A list of tool names, such as ['searchCreators', 'getCreator']. |
baseURL | https:/ | Another Yap Factory host, for testing. |
headers, fetch | none | Extra headers, or your own fetch. |
Results and errors
- Each tool returns the API's JSON:
{ data }, and lists also carrynextCursorandhasMore. 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.messageis written for people. See errors. - Calls that change something send an
Idempotency-Keymade 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.
| Tool | For | Kind |
|---|---|---|
getAccount | Everyone | Reads |
listDeals | Everyone | Reads |
getDeal | Everyone | Reads |
sendDealMessage | Everyone | Reaches people: asks first |
searchCreators | Brands | Reads |
getCreator | Brands | Reads |
listProducts | Brands | Reads |
listCampaigns | Brands | Reads |
getCampaign | Brands | Reads |
createCampaignDraft | Brands | Your own things |
updateCampaignBrief | Brands | Your own things |
publishCampaign | Brands | Reaches people: asks first |
setCampaignStatus | Brands | Reaches people: asks first |
inviteCreators | Brands | Reaches people: asks first |
passOnCreator | Brands | Reaches people: asks first |
requestRevision | Brands | Reaches people: asks first |
browseCampaigns | Creators | Reads |
viewCampaignBrief | Creators | Reads |
askToJoin | Creators | Reaches people: asks first |
respondToInvite | Creators | Reaches people: asks first |
listPostAccounts | Brands | Reads |
getPostAccount | Brands | Reads |
listPostableVideos | Brands | Reads |
preparePostUpload | Brands | Your own things |
schedulePost | Brands | Reaches people: asks first |
listPosts | Brands | Reads |
updatePost | Brands | Your own things |
cancelPost | Brands | Your own things |
startDeal | Brands | Returns a link |
approveDraft | Brands | Returns a link |
Source and support
- npm: @yapfactory/ai-sdk. MIT licence.
- Source: github.com/shehrum/yapfactory-plugin.
- Questions: support@yapfactory.com.