import os
from swarms_client import SwarmsClient
client = SwarmsClient(api_key=os.environ["SWARMS_API_KEY"])
# The style guide becomes the rules string. Every agent in the swarm sees it,
# and the Brand Reviewer is told to enforce it line by line.
BRAND_RULES = """
- Voice: direct, specific, second person. No exclamation marks.
- Never claim 'the best', 'the fastest' or any superlative without a source.
- Do not name competitors. Describe the category instead.
- Prices are always written with the currency symbol and no decimals.
- Product name is 'Ledgerline' with a capital L, never 'LedgerLine'.
"""
response = client.swarms.run(
name="Spring Launch Pipeline",
description="Research, draft, brand review and channel formatting for one campaign.",
swarm_type="SequentialWorkflow",
task=(
"Campaign: Ledgerline invoicing for freelancers, spring launch. Offer: three "
"months free on annual plans. Audience: freelance designers and developers in "
"the US and UK. Deliver a landing page hero, a three-email welcome sequence and "
"six paid social variants (two per platform: LinkedIn, Instagram, X)."
),
rules=BRAND_RULES,
agents=[
{
"agent_name": "Audience Researcher",
"description": "Segments, pains and competitor claims to avoid.",
"system_prompt": (
"You are a marketing researcher. Describe the audience segments, the "
"words they use for the problem, and the claims competitors already make "
"so the copy can avoid them. Return a short brief with headings."
),
"model_name": "gemini-2.5-flash", # fast and cheap for a summary pass
"max_loops": 1,
},
{
"agent_name": "Copywriter",
"description": "Drafts for every channel from the brief.",
"system_prompt": (
"You are a senior copywriter. Using the research brief, write the landing "
"hero (headline, subhead, CTA), three welcome emails (subject, preview, "
"body) and six paid social variants. Label each piece."
),
"model_name": "claude-sonnet-5-5", # strongest writer in the pipeline
"max_loops": 1,
},
{
"agent_name": "Brand Reviewer",
"description": "Enforces the rules on every line.",
"system_prompt": (
"You are the brand editor. Check every line of the drafts against the "
"rules. Rewrite anything that breaks a rule and list each change with the "
"rule it broke. Keep pieces that pass unchanged."
),
"model_name": "gpt-5.4",
"max_loops": 1,
},
{
"agent_name": "Channel Formatter",
"description": "Character limits and tracking.",
"system_prompt": (
"You format approved copy per channel. Enforce character limits for each "
"platform, append UTM parameters to every link, and return JSON keyed by "
"channel and variant."
),
"model_name": "gpt-4.1-mini", # mechanical step, small model
"max_loops": 1,
},
],
max_loops=1,
)
print(response)