

Build an AI Presentation Agent: Complete Developer Guide
AI agents are transforming how software creates content. An AI presentation agent can generate, customize, and deliver professional slide decks as part of automated workflows — from CRM pipelines to internal reporting tools.
This guide walks you through building a production-ready presentation agent using the 2Slides API.
Architecture Overview
A presentation agent typically follows this flow:
User Request → Agent Logic → 2Slides API → Poll Job → Deliver Result
↓
Context Gathering
(data, templates, brand assets)Core Components
- Input Handler — receives presentation requests (text, data, files)
- Context Builder — enriches requests with templates, brand info, data
- Generation Engine — calls 2Slides API to create slides
- Status Monitor — polls job status until completion
- Delivery Layer — returns download links, sends via email, posts to Slack
Getting Started
1. Get Your API Key
Sign up at 2slides.com and create an API key at 2slides.com/api.
2. Install Dependencies
npm install node-fetch dotenv3. Basic Agent Implementation
import fetch from 'node-fetch';
class PresentationAgent {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://2slides.com/api/v1';
}
async generateSlides({ topic, themeId, language = 'en', resolution = '2K' }) {
// Step 1: Start generation
const response = await fetch(`${this.baseUrl}/slides/generate`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
userInput: topic,
themeId,
responseLanguage: language,
resolution,
mode: 'async'
})
});
const job = await response.json();
if (!response.ok) throw new Error(job.error || 'Generation failed');
// Step 2: Poll until complete
return await this.waitForCompletion(job.jobId);
}
async waitForCompletion(jobId, maxWait = 300000) {
const start = Date.now();
while (Date.now() - start < maxWait) {
const response = await fetch(`${this.baseUrl}/jobs/${jobId}`, {
headers: { 'Authorization': `Bearer ${this.apiKey}` }
});
const status = await response.json();
if (status.status === 'success') return status;
if (status.status === 'failed') throw new Error('Generation failed');
await new Promise(r => setTimeout(r, 3000));
}
throw new Error('Generation timed out');
}
async generateFromFile({ fileUrl, prompt, themeId }) {
const response = await fetch(`${this.baseUrl}/slides/create-pdf-slides`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
fileUrl,
userInput: prompt,
themeId,
mode: 'async'
})
});
const job = await response.json();
return await this.waitForCompletion(job.jobId);
}
async generateWithDesign({ topic, referenceImageUrl, resolution = '2K' }) {
const response = await fetch(`${this.baseUrl}/slides/create-like-this`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
userInput: topic,
designStyle: {
global: { referenceImageUrl }
},
resolution,
mode: 'async'
})
});
const job = await response.json();
return await this.waitForCompletion(job.jobId);
}
async addNarration({ jobId, mode = 'single', voice = 'Charon' }) {
const response = await fetch(`${this.baseUrl}/slides/generate-narration`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ jobId, mode, voice, contentMode: 'concise' })
});
return await response.json();
}
}
// Usage
const agent = new PresentationAgent('sk-2slides-xxx');
const result = await agent.generateSlides({
topic: 'Q1 2026 Business Review',
themeId: 'mckinsey-theme-id',
resolution: '2K'
});
console.log('Download:', result.downloadUrl);Python Implementation
import requests
import time
class PresentationAgent:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://2slides.com/api/v1'
self.headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
def generate_slides(self, topic, theme_id=None, language='en', resolution='2K'):
response = requests.post(
f'{self.base_url}/slides/generate',
headers=self.headers,
json={
'userInput': topic,
'themeId': theme_id,
'responseLanguage': language,
'resolution': resolution,
'mode': 'async'
}
)
response.raise_for_status()
job = response.json()
return self._wait_for_completion(job['jobId'])
def generate_from_file(self, file_url, prompt, theme_id=None):
response = requests.post(
f'{self.base_url}/slides/create-pdf-slides',
headers=self.headers,
json={
'fileUrl': file_url,
'userInput': prompt,
'themeId': theme_id,
'mode': 'async'
}
)
response.raise_for_status()
job = response.json()
return self._wait_for_completion(job['jobId'])
def _wait_for_completion(self, job_id, max_wait=300):
start = time.time()
while time.time() - start < max_wait:
response = requests.get(
f'{self.base_url}/jobs/{job_id}',
headers=self.headers
)
status = response.json()
if status['status'] == 'success':
return status
if status['status'] == 'failed':
raise Exception('Generation failed')
time.sleep(3)
raise TimeoutError('Generation timed out')
# Usage
agent = PresentationAgent('sk-2slides-xxx')
result = agent.generate_slides('AI Trends 2026', resolution='4K')
print(f"Download: {result['downloadUrl']}")Advanced Patterns
Pattern 1: Template-Based Generation
Pre-configure themes for different use cases:
const TEMPLATES = {
'pitch-deck': { themeId: 'apple-id', resolution: '2K' },
'quarterly-review': { themeId: 'mckinsey-id', resolution: '2K' },
'training': { themeId: 'corporate-id', resolution: '1K' },
'social-media': { themeId: 'saul-bass-id', resolution: '4K', aspectRatio: '1:1' },
};
async function generateByType(type, topic) {
const config = TEMPLATES[type];
return agent.generateSlides({ topic, ...config });
}Pattern 2: Data Pipeline Integration
Connect to your data sources:
async function weeklyReport(dataSource) {
// 1. Fetch latest data
const data = await dataSource.getWeeklyMetrics();
// 2. Format as presentation input
const topic = `Weekly Report: Revenue $${data.revenue}, Users ${data.users}, Churn ${data.churn}%`;
// 3. Generate slides
const result = await agent.generateSlides({ topic, themeId: 'mckinsey-id' });
// 4. Deliver
await slackBot.postMessage('#team-updates', `Weekly report ready: ${result.downloadUrl}`);
}Pattern 3: Multi-Format Output
Generate slides + narration + video in one pipeline:
async function fullPresentation(topic) {
// 1. Generate slides
const slides = await agent.generateSlides({ topic });
// 2. Add voice narration
await agent.addNarration({ jobId: slides.jobId, mode: 'multi', voice: 'Charon' });
// 3. Download with audio
const download = await fetch(`${agent.baseUrl}/slides/download-slides-pages-voices`, {
method: 'POST',
headers: agent.headers,
body: JSON.stringify({ jobId: slides.jobId })
});
return download.json();
}Production Considerations
Rate Limiting
- Default: 60 requests/minute
- Handle 429 responses with exponential backoff
- Use async mode for batch operations
Error Handling
- Wrap all API calls in try/catch
- Implement retry logic for transient failures
- Log job IDs for debugging
Cost Management
- Track credit usage per generation
- Set budget alerts in your 2Slides dashboard
- Use lower resolutions for internal/draft content
Security
- Store API keys in environment variables, never in code
- Use server-side API calls only — never expose keys to clients
- Implement request signing for webhook callbacks
Frequently Asked Questions
Can I build a SaaS product on top of 2Slides API?
Yes — the API is designed for production use. There are no restrictions on commercial applications.
What's the maximum concurrent generation limit?
The API handles concurrent requests via rate limiting. For high-volume needs, contact the 2Slides team for enterprise limits.
Is there a webhook for job completion?
Currently, use polling via the jobs endpoint. Webhook support is on the roadmap.
Build your presentation agent — get your API key at 2Slides and start generating slides programmatically.
About 2Slides
Create stunning AI-powered presentations in seconds. Transform your ideas into professional slides with 2slides AI Agent.
Try For Free