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.
Building in TypeScript? Use the Vercel AI SDK package. Inside ChatGPT or Claude? Use the MCP server: no code.
Install
pip install yapfactoryPython 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.
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
| Option | Default | What it does |
|---|---|---|
api_key | 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 ["search_creators", "get_creator"]. |
approve | none | Toolkits only: approve(tool_name, args) -> bool, asked before each tool that reaches people. |
base_url | https:/ | Another Yap Factory host, for testing. |
timeout, headers | 30, none | Seconds per request, and extra headers. |
Results and errors
- Each call returns the API's JSON:
{"data": …}, and lists also carrynextCursorandhasMore. Money is{minor, currency, formatted}. - When the API refuses a call, the client raises
YapFactoryErrorwithcode,message,status,request_idandretry_after_seconds. The tools return the same fields as{"error": {…}}instead of raising, so the model can tell the person what happened.messageis 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, passidempotency_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.
| Tool | For | Kind |
|---|---|---|
get_account | Everyone | Reads |
list_deals | Everyone | Reads |
get_deal | Everyone | Reads |
send_deal_message | Everyone | Reaches people: asks first |
search_creators | Brands | Reads |
get_creator | Brands | Reads |
list_products | Brands | Reads |
list_campaigns | Brands | Reads |
get_campaign | Brands | Reads |
create_campaign_draft | Brands | Your own things |
update_campaign_brief | Brands | Your own things |
publish_campaign | Brands | Reaches people: asks first |
set_campaign_status | Brands | Reaches people: asks first |
invite_creators | Brands | Reaches people: asks first |
pass_on_creator | Brands | Reaches people: asks first |
request_revision | Brands | Reaches people: asks first |
browse_campaigns | Creators | Reads |
view_campaign_brief | Creators | Reads |
ask_to_join | Creators | Reaches people: asks first |
respond_to_invite | Creators | Reaches people: asks first |
list_post_accounts | Brands | Reads |
get_post_account | Brands | Reads |
list_postable_videos | Brands | Reads |
prepare_post_upload | Brands | Your own things |
schedule_post | Brands | Reaches people: asks first |
list_posts | Brands | Reads |
update_post | Brands | Your own things |
cancel_post | Brands | Your own things |
list_webhooks | Everyone | Reads |
get_webhook | Everyone | Reads |
create_webhook | Everyone | Your own things |
delete_webhook | Everyone | Your own things |
list_events | Everyone | Reads |
start_deal | Brands | Returns a link |
approve_draft | Brands | Returns a link |
Source and support
- PyPI: yapfactory. MIT licence.
- Source: github.com/shehrum/yapfactory-plugin.
- Questions: support@yapfactory.com.