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

Developers

Python, LangChain and CrewAI

Give your Python agent Yap Factory tools: search creators, run campaigns, keep deals moving and schedule posts. yapfactory is an API client that also turns every API operation into a LangChain or CrewAI tool.

View as Markdown

Building in TypeScript? Use the Vercel AI SDK package. Inside ChatGPT or Claude? Use the MCP server: no code.

Install

pip install yapfactory

Python 3.9 or later (CrewAI needs 3.10). The client needs only httpx.

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 api_key.

Quick start

from yapfactory import YapFactory

yf = YapFactory()  # reads YAPFACTORY_API_KEY

creators = yf.call("search_creators", niches=["skincare"], limit=3)
for c in creators["data"]:
    print(c["name"], c["rate"]["formatted"], c["summary"])

access="read" gives only the tools that change nothing, which suits a first try. Arguments use the API's names (campaignId) or snake_case (campaign_id). AsyncYapFactory is the same client with await, and the LangChain tools work with ainvoke.

Ask before anything reaches people

Some tools tell other people straight away: publishing a campaign, inviting creators, messages, answering invites and scheduled posts. In LangChain each one is tagged yapfactory:reaches-people, and toolkit.interrupt_on() plugs into HumanInTheLoopMiddleware, so the agent stops and waits for your user's yes.

from langchain.agents import create_agent
from langchain.agents.middleware import HumanInTheLoopMiddleware
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.types import Command
from yapfactory.langchain import YapFactoryToolkit

toolkit = YapFactoryToolkit()

agent = create_agent(
    "anthropic:claude-sonnet-4-5",
    tools=toolkit.get_tools(),
    middleware=[HumanInTheLoopMiddleware(interrupt_on=toolkit.interrupt_on())],
    checkpointer=InMemorySaver(),
)
config = {"configurable": {"thread_id": "1"}}

result = agent.invoke(
    {"messages": [{"role": "user", "content": "Draft a UGC campaign for my app, then invite the three best-fitting creators."}]},
    config,
)
# result["__interrupt__"] lists the calls waiting for a yes. Show them to your user, then:
agent.invoke(Command(resume={"decisions": [{"type": "approve"}]}), config)

CrewAI has no approval step of its own, so the CrewAI tools leave those out unless you pass approve, a function asked before each one. A no comes back to the model as a not_approved error.

def approve(tool_name: str, args: dict) -> bool:
    return input(f"Run {tool_name} with {args}? [y/N] ").strip().lower() == "y"

tools = yapfactory_tools(approve=approve)

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
api_keyYAPFACTORY_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 ["search_creators", "get_creator"].
approvenoneToolkits only: approve(tool_name, args) -> bool, asked before each tool that reaches people.
base_urlhttps://yapfactory.com/api/v1Another Yap Factory host, for testing.
timeout, headers30, noneSeconds per request, and extra headers.

Results and errors

  • Each call 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 client raises YapFactoryError with code, message, status, request_id and retry_after_seconds. The tools return the same fields as {"error": {…}} instead of raising, so the model can tell the person what happened. message is written for people. See errors.
  • Calls that change something send an Idempotency-Key. The tools make it from the model's tool call id, so a retried step never runs twice; with the client, pass idempotency_key=.
  • Rate limits are per key: 120 reads, 20 writes and 10 calls that reach people a minute.

OpenAI Agents SDK

No package needed: the OpenAI Agents SDK talks to the MCP server directly, with your API key.

import asyncio, os
from agents import Agent, Runner
from agents.mcp import MCPServerStreamableHttp

async def main():
    async with MCPServerStreamableHttp(
        name="Yap Factory",
        params={
            "url": "https://yapfactory.com/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['YAPFACTORY_API_KEY']}"},
        },
    ) as yapfactory:
        agent = Agent(name="UGC scout", instructions="Help the brand find UGC creators.", mcp_servers=[yapfactory])
        result = await Runner.run(agent, "Find three UGC creators for my skincare campaign.")
        print(result.final_output)

asyncio.run(main())

The tools

One tool per API operation, named like the operation. Each links to its reference page.

ToolForKind
get_accountEveryoneReads
list_dealsEveryoneReads
get_dealEveryoneReads
send_deal_messageEveryoneReaches people: asks first
search_creatorsBrandsReads
get_creatorBrandsReads
list_productsBrandsReads
list_campaignsBrandsReads
get_campaignBrandsReads
create_campaign_draftBrandsYour own things
update_campaign_briefBrandsYour own things
publish_campaignBrandsReaches people: asks first
set_campaign_statusBrandsReaches people: asks first
invite_creatorsBrandsReaches people: asks first
pass_on_creatorBrandsReaches people: asks first
request_revisionBrandsReaches people: asks first
browse_campaignsCreatorsReads
view_campaign_briefCreatorsReads
ask_to_joinCreatorsReaches people: asks first
respond_to_inviteCreatorsReaches people: asks first
list_post_accountsBrandsReads
get_post_accountBrandsReads
list_postable_videosBrandsReads
prepare_post_uploadBrandsYour own things
schedule_postBrandsReaches people: asks first
list_postsBrandsReads
update_postBrandsYour own things
cancel_postBrandsYour own things
list_webhooksEveryoneReads
get_webhookEveryoneReads
create_webhookEveryoneYour own things
delete_webhookEveryoneYour own things
list_eventsEveryoneReads
start_dealBrandsReturns a link
approve_draftBrandsReturns a link

Source and support