Refresh README, quickstart, and the docs index around Browser, Desktop, A0 CLI, projects, memory, skills, profiles, and model presets. Add optimized scoped screenshots for Web UI, Browser, Desktop, and CLI workflows. Trim architecture-heavy developer pages toward DeepWiki handoffs so local docs stay focused on practical user guidance.
7.7 KiB
Adding External APIs Without Code
One of Agent Zero's most powerful capabilities is the ability to integrate external APIs on the fly without writing any code. By simply providing API documentation or code snippets, the agent can learn to use new services and remember how to use them in future conversations.
This tutorial demonstrates how to integrate Google's image generation API from Google AI Studio - but the same process works for any public API.
How It Works
Agent Zero can:
- Analyze API code - Understand how to use an API from provided snippets or documentation
- Execute the integration - Run the code to accomplish your task
- Remember the solution - Store the approach in its memory for future use
- Manage credentials - Use secrets stored globally or per-project for authentication
This means you can add capabilities like image generation, translation services, payment processing, or any other API-based feature simply by showing the agent how it works once.
Example: Image Generation with Google AI Studio
Let's walk through adding image generation capabilities using Google's Gemini API.
Step 1: Get the API Code
First, we need the code snippet that shows how to use the API.
- Go to Google AI Studio
- Use the interface to create or test an image generation prompt
- Click "Get Code" in the UI
- Select "Python" as the language
- Download the code file (or copy it to clipboard)
Tip
Most API platforms (OpenAI, Anthropic, Replicate, etc.) provide similar "Get Code" features or have documentation with ready-to-use snippets.
Step 2: Provide the Code to Agent Zero
Now we'll tell Agent Zero to use this code:
- Open a chat with Agent Zero
- Send a message like: "Use this code to generate an image of the Agent Zero logo"
- Either:
- Attach the downloaded Python file, or
- Paste the code snippet into the chat
Agent Zero will analyze the code and understand:
- What dependencies are needed (
google-genaipackage) - How to structure the API request
- What parameters are required
- How to handle the response
Step 3: Configure API Credentials
On first run, Agent Zero will attempt to use the API but discover it needs an API key:
Agent Zero will tell you:
- What credential is missing (e.g.,
GEMINI_API_KEY) - Where to configure it (Settings → External Services or Project settings)
Adding the API Key
You have two options for storing credentials:
Option 1: Global Secrets (available to all chats and projects)
- Click the Settings icon in the sidebar
- Go to External Services
- Add a new line:
GEMINI_API_KEY=your_actual_key_here - Click Save
Option 2: Project Secrets (available only within a specific project)
- Open your project settings
- Go to the Secrets tab
- Add the key-value pair
- Save the project
Note
Global secrets are ideal for APIs you use frequently across different projects. Project secrets are better for client-specific or project-specific integrations.
Step 4: Generate the Image
After configuring the API key, tell Agent Zero to proceed:
"I set the API key in secrets. Now you can use it."
Agent Zero will:
- Retrieve the API key from secrets
- Install required dependencies (
google-genaipackage) - Execute the image generation code
- Save the generated image to disk
- Report the file location
The agent confirms:
- Mission complete
- File location:
/root/agent_zero_logo_0.jpg - File size: 378 KB
How Memory Helps
Agent Zero can save useful API patterns in memory so you do not have to explain the same integration every time.
For example, it may remember:
- what the API is useful for;
- what credential name is needed;
- which package or example worked;
- how you prefer to use that service in this project.
Important
Memory still needs curation. If Agent Zero keeps using an old API pattern, wrong credential name, or outdated package, open Memory and fix or remove that memory. Memory should help the agent think, not trap it in yesterday's answer.
See the Memory Guide for cleanup and curation tips.
Use Cases
This approach works for any external API. Common examples:
Communication & Notifications
- SendGrid: Email delivery
- Twilio: SMS and phone calls
- Slack/Discord: Message webhooks
- Telegram: Bot interactions
Data & Analytics
- Google Sheets API: Spreadsheet automation
- Airtable: Database operations
- Stripe: Payment processing
- Plaid: Banking data
Content & Media
- Unsplash/Pexels: Stock photos
- ElevenLabs: Text-to-speech
- Whisper API: Speech-to-text
- Stable Diffusion: Image generation
- Replicate: Various AI models
Development Tools
- GitHub API: Repository management
- Jira/Linear: Issue tracking
- Vercel/Netlify: Deployment
- Docker Hub: Container registry
Specialized Services
- WeatherAPI: Weather data
- Google Maps: Geocoding, directions
- Currency exchange: Forex rates
- Translation APIs: Multi-language support
Best Practices
1. Start with Official Examples
Always use code snippets from official documentation or API providers' "Get Code" features. These are:
- Tested and working
- Up-to-date with latest API versions
- Include proper error handling
- Show recommended practices
2. Organize Credentials
For personal/global APIs:
- Store in Settings → External Services
- Use clear naming:
SERVICE_API_KEY,SERVICE_SECRET - Add comments to document what each key is for
For project-specific APIs:
- Store in Project Settings → Secrets
- Keeps client data isolated
- Prevents accidental cross-project usage
3. Document in Project Instructions
When integrating APIs for a specific project, add notes to the project instructions:
## Available APIs
This project has access to:
- **Gemini Image Generation**: Use for creating visuals and illustrations
- Credentials: GEMINI_API_KEY (configured in project secrets)
- Best for: Professional graphics, concept art, UI mockups
- **SendGrid Email**: Use for sending automated emails
- Credentials: SENDGRID_API_KEY
- Best for: Notifications, reports, customer communications
This helps the agent understand what tools are available for the current project.
Advanced: Custom API Wrappers
For APIs you use frequently, you can have Agent Zero create reusable wrapper functions:
"Create a Python module called image_gen.py with a function generate_image(prompt, style='professional') that uses the Gemini API. Include error handling and save the image to the current project folder."
Agent Zero will:
- Create a clean, reusable module
- Add proper documentation
- Include error handling
- Make it easy to call from future tasks
Then in future chats:
"Use the image_gen module to create a logo", and it just works!
Conclusion
By showing Agent Zero a working API example, you can:
- add a new service to a project;
- keep credentials in settings or project secrets;
- reuse working patterns later;
- clean up memory when an old pattern stops helping.
This is not magic permanence. It works best when you keep the example, secrets, project instructions, and memories tidy.




