marketplace_prompt_id parameter.
Prerequisites
Before using this feature, ensure you have:- Swarms installed:
- A Swarms API key - Get yours at https://swarms.world/platform/api-keys
- Set your API key as an environment variable:
Quick Start
Basic Usage
Load a marketplace prompt in one line by providing themarketplace_prompt_id:
Finding Prompt IDs
To find prompt IDs:- Visit the Swarms Marketplace
- Browse or search for prompts that fit your use case
- Click on a prompt to view its details page
- Copy the prompt ID from the URL - The prompt ID is the UUID in the URL path
- Marketplace URL:
https://swarms.world/prompt/75fc0d28-b0d0-4372-bc04-824aa388b7d2 - Prompt ID:
75fc0d28-b0d0-4372-bc04-824aa388b7d2
Complete Example
Here’s a complete working example:How It Works
When you provide amarketplace_prompt_id, the agent:
- Fetches the prompt from the Swarms Marketplace API during initialization
- Sets the system prompt from the marketplace data
- Optionally updates agent metadata - If you haven’t set a custom
agent_nameoragent_description, these will be populated from the marketplace prompt data - Logs the operation - You’ll see a confirmation message when the prompt is loaded successfully
Configuration Options
Combining with Other Parameters
You can combinemarketplace_prompt_id with any other agent parameters:
Overriding Agent Name and Description
By default, the agent will use the name and description from the marketplace prompt if you haven’t set them. To use your own:Error Handling
The feature includes built-in error handling:Prompt Not Found
If the prompt ID doesn’t exist:Missing API Key
If theSWARMS_API_KEY environment variable is not set:
Best Practices
- Store prompt IDs in configuration - Keep your prompt IDs in environment variables or config files for easy updates
- Handle errors gracefully - Wrap agent creation in try-except blocks for production code
- Cache prompts for offline use - If you need offline capability, fetch and store prompts locally as backup
- Version your prompts - When updating marketplace prompts, consider creating new versions rather than overwriting
- Monitor prompt usage - Track which prompts are being used in your applications for analytics
Troubleshooting
| Issue | Solution |
|---|---|
ValueError: Swarms API key is not set | Set the SWARMS_API_KEY environment variable |
ValueError: Prompt not found | Verify the prompt ID is correct on the marketplace |
Connection timeout | Check your internet connection and try again |
| Agent not using expected prompt | Ensure you’re not also setting system_prompt parameter |
Related Resources
- Swarms Marketplace - Browse available prompts
- Publishing Prompts - Share your own prompts
- Agent Reference - Full agent documentation
- API Key Management - Manage your API keys