Discover, share, and monetize production-ready prompts and agents through the Swarms Marketplace
The Swarms Marketplace is a platform for discovering and sharing production-ready prompts, agent configurations, and tools. Load prompts in a single line of code or publish your own creations to the community.
from swarms import Agent# Create agent with marketplace promptagent = Agent( agent_name="Marketplace-Agent", model_name="gpt-4o", marketplace_prompt_id="550e8400-e29b-41d4-a716-446655440000", max_loops=1,)# The system prompt is automatically loaded from the marketplaceresult = agent.run("Execute the task")
When you provide a marketplace_prompt_id, the agent automatically fetches the prompt from the marketplace and sets it as the system prompt.
from swarms import Agent# Create agent with auto-publish enabledagent = Agent( agent_name="Medical-Diagnosis-Agent", model_name="gpt-4o", system_prompt="""You are an expert medical diagnostician specializing in: - Differential diagnosis - Medical imaging interpretation - Treatment planning - Patient case analysis Provide evidence-based recommendations following medical best practices. """, description="Expert medical diagnosis and treatment planning agent", use_cases=[ { "title": "Differential Diagnosis", "description": "Analyze symptoms to generate differential diagnoses" }, { "title": "Medical Imaging", "description": "Interpret X-rays, CT scans, and MRI results" }, ], tags="medical,healthcare,diagnosis,treatment", category="healthcare", publish_to_marketplace=True, # Auto-publish on initialization)# Agent is automatically published to marketplace
Make sure to set the SWARMS_API_KEY environment variable before publishing. Get your API key at swarms.world/platform/api-keys
from swarms.utils.fetch_prompts_marketplace import ( fetch_prompts_from_marketplace)import httpxtry: result = fetch_prompts_from_marketplace( name="non-existent-prompt", ) if result is None: print("Prompt not found") else: name, description, prompt = result print(f"Loaded: {name}")except httpx.HTTPStatusError as e: print(f"HTTP error: {e}")except Exception as e: print(f"Error: {e}")
Load a sophisticated trading agent from the marketplace:
from swarms import Agent# Real marketplace prompt for quantitative tradingtrading_agent = Agent( agent_name="Quant-Trader", model_name="gpt-4o", marketplace_prompt_id="6d165e47-1827-4abe-9a84-b25005d8e3b4", max_loops=1, verbose=True,)result = trading_agent.run( "Analyze the current market conditions for tech stocks and suggest a trading strategy")print(result)
from swarms import Agent# Medical AI agent from marketplacemedical_agent = Agent( agent_name="Medical-Assistant", model_name="gpt-4o", marketplace_prompt_id="75fc0d28-b0d0-4372-bc04-824aa388b7d2", max_loops=1,)result = medical_agent.run( "Provide a differential diagnosis for a patient with fever and chest pain")
from swarms.utils.swarms_marketplace_utils import ( add_prompt_to_marketplace)research_prompt = """You are an expert research assistant specializing in:- Academic paper analysis- Literature review synthesis- Research methodology design- Data interpretation- Citation managementProvide comprehensive, well-cited research support.Always verify sources and maintain academic integrity."""use_cases = [ { "title": "Literature Review", "description": "Synthesize findings from multiple research papers" }, { "title": "Research Design", "description": "Design robust research methodologies" }, { "title": "Data Analysis", "description": "Interpret research data and statistics" },]response = add_prompt_to_marketplace( name="academic-research-assistant", prompt=research_prompt, description="Comprehensive research assistant for academic and scientific work", use_cases=use_cases, tags="research,academic,science,literature-review,methodology", is_free=True, category="research",)print(f"Research agent published: {response}")
# Check if API key is setimport osapi_key = os.getenv("SWARMS_API_KEY")if not api_key: print("Set your API key: export SWARMS_API_KEY='your-key'") print("Get your key at: https://swarms.world/platform/api-keys")
from swarms.utils.fetch_prompts_marketplace import ( fetch_prompts_from_marketplace)result = fetch_prompts_from_marketplace( prompt_id="invalid-id",)if result is None: print("Prompt not found. Check the prompt ID or name.")else: print("Prompt loaded successfully")
try: add_prompt_to_marketplace( name="test-prompt", prompt="Test", description="Test", use_cases=[{"title": "Test", "description": "Test"}], )except Exception as e: if "401" in str(e) or "authentication" in str(e).lower(): print("Authentication failed. Check your API key at:") print("https://swarms.world/platform/api-keys") else: print(f"Error: {e}")