Skip to main content
This tutorial shows how to run a vision-capable agent that uses a prebuilt prompt from the Swarms marketplace. You’ll encode a local image to base64, configure the agent with a marketplace_prompt_id, and get a response (e.g., “What city is this image of?”).
You need an API key and the Python client. Get your key at swarms.world/platform/api-keys. Find marketplace prompts on swarms.world or via the Query Prompts API.

Step 1 — Set up the client and API key

Install the client and load your API key from a .env file:
Create a .env file in your project root:
Then initialize the Swarms client in your script:
Keep your API key out of version control. Use .env and add .env to your .gitignore.

Step 2 — Encode your image and pick a marketplace prompt

Encode your image to base64 (required for the vision API). Use a local file path or replace with your own image:
Choose a marketplace prompt ID for your agent. The prompt defines the agent’s system prompt, name, and description. You can browse prompts on swarms.world or query them via the Prompts API. Use a prompt that fits vision or general analysis. Example ID used below: 72021048-6f31-48b6-b624-7732e6f93437.

Step 3 — Run the agent with the image and task

Build an agent_config that uses the marketplace prompt and a vision-capable model, then call client.agent.run with your task and img:
When marketplace_prompt_id is set, the API fetches the prompt from the marketplace and uses it as the agent’s system prompt; you don’t need to pass system_prompt, agent_name, or description yourself.

Complete script

Here is the full script in one place:

Summary

For more details, see Vision Capabilities and Using marketplace prompts with agents.