Simple Document to Presentation
Complete bash script example:Copy
#!/bin/bash
API_KEY="pk_your_api_key_here"
BASE_URL="https://poe.poesius.com/api/v1"
DOCUMENT_PATH="/path/to/document.pdf"
NUM_SLIDES=20
TEMPLATE_ID="123e4567-e89b-12d3-a456-426614174000"
# Step 1: Generate slides
RESPONSE=$(curl -s -X POST "${BASE_URL}/slides/generate-from-doc" \
-H "X-API-Key: ${API_KEY}" \
-F "document=@${DOCUMENT_PATH}" \
-F "instructions=Create a professional presentation" \
-F "num_slides=${NUM_SLIDES}" \
-F "template_id=${TEMPLATE_ID}")
PRESENTATION_ID=$(echo $RESPONSE | jq -r '.presentation_id')
echo "Presentation ID: ${PRESENTATION_ID}"
# Step 2: Poll for completion
while true; do
STATUS=$(curl -s -X GET "${BASE_URL}/presentations/${PRESENTATION_ID}" \
-H "X-API-Key: ${API_KEY}" | jq -r '.status')
echo "Status: ${STATUS}"
if [ "$STATUS" = "completed" ]; then
break
elif [ "$STATUS" = "failed" ]; then
echo "Generation failed!"
exit 1
fi
sleep 5
done
# Step 3: Download
curl -X GET "${BASE_URL}/presentations/${PRESENTATION_ID}/download" \
-H "X-API-Key: ${API_KEY}" \
-o presentation.pptx
echo "Downloaded: presentation.pptx"
Python Example
Copy
import requests
import time
import json
API_KEY = "pk_your_api_key_here"
BASE_URL = "https://poe.poesius.com/api/v1"
def generate_presentation(document_path, instructions, num_slides, template_id=None):
"""Generate a presentation from a document"""
# Step 1: Generate slides
with open(document_path, 'rb') as f:
files = {'document': f}
data = {
'instructions': instructions,
'num_slides': num_slides
}
if template_id:
data['template_id'] = template_id
response = requests.post(
f"{BASE_URL}/slides/generate-from-doc",
headers={'X-API-Key': API_KEY},
files=files,
data=data
)
response.raise_for_status()
result = response.json()
presentation_id = result['presentation_id']
print(f"Generation started. Presentation ID: {presentation_id}")
# Step 2: Poll for completion
while True:
response = requests.get(
f"{BASE_URL}/presentations/{presentation_id}",
headers={'X-API-Key': API_KEY}
)
response.raise_for_status()
data = response.json()
status = data['status']
print(f"Status: {status}")
if status == 'completed':
break
elif status == 'failed':
raise Exception(f"Generation failed: {data.get('error')}")
time.sleep(5)
# Step 3: Download
response = requests.get(
f"{BASE_URL}/presentations/{presentation_id}/download",
headers={'X-API-Key': API_KEY}
)
response.raise_for_status()
output_path = f"presentation_{presentation_id}.pptx"
with open(output_path, 'wb') as f:
f.write(response.content)
print(f"Downloaded: {output_path}")
return output_path
# Usage
if __name__ == "__main__":
generate_presentation(
document_path="document.pdf",
instructions="Create a professional presentation highlighting key findings",
num_slides=15,
template_id="123e4567-e89b-12d3-a456-426614174000"
)
Node.js Example
Copy
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
const API_KEY = 'pk_your_api_key_here';
const BASE_URL = 'https://poe.poesius.com/api/v1';
async function generatePresentation(documentPath, instructions, numSlides, templateId) {
// Step 1: Generate slides
const form = new FormData();
form.append('document', fs.createReadStream(documentPath));
form.append('instructions', instructions);
form.append('num_slides', numSlides);
if (templateId) {
form.append('template_id', templateId);
}
const generateResponse = await axios.post(
`${BASE_URL}/slides/generate-from-doc`,
form,
{
headers: {
'X-API-Key': API_KEY,
...form.getHeaders()
}
}
);
const presentationId = generateResponse.data.presentation_id;
console.log(`Generation started. Presentation ID: ${presentationId}`);
// Step 2: Poll for completion
while (true) {
const statusResponse = await axios.get(
`${BASE_URL}/presentations/${presentationId}`,
{
headers: { 'X-API-Key': API_KEY }
}
);
const status = statusResponse.data.status;
console.log(`Status: ${status}`);
if (status === 'completed') {
break;
} else if (status === 'failed') {
throw new Error(`Generation failed: ${statusResponse.data.error}`);
}
await new Promise(resolve => setTimeout(resolve, 5000));
}
// Step 3: Download
const downloadResponse = await axios.get(
`${BASE_URL}/presentations/${presentationId}/download`,
{
headers: { 'X-API-Key': API_KEY },
responseType: 'arraybuffer'
}
);
const outputPath = `presentation_${presentationId}.pptx`;
fs.writeFileSync(outputPath, downloadResponse.data);
console.log(`Downloaded: ${outputPath}`);
return outputPath;
}
// Usage
generatePresentation(
'document.pdf',
'Create a professional presentation',
15,
'123e4567-e89b-12d3-a456-426614174000'
).catch(console.error);
Template Management Examples
Use these calls to list templates and set a default template for future generation requests.Copy
#!/bin/bash
API_KEY="pk_your_api_key_here"
BASE_URL="https://poe.poesius.com/api/v1"
TEMPLATE_ID="123e4567-e89b-12d3-a456-426614174000"
# List templates
curl -X GET "${BASE_URL}/templates/?limit=50&offset=0" \
-H "X-API-Key: ${API_KEY}"
# Set default template by path parameter
curl -X POST "${BASE_URL}/templates/${TEMPLATE_ID}/set-default" \
-H "X-API-Key: ${API_KEY}"
# Set default template by request body
curl -X POST "${BASE_URL}/templates/default" \
-H "X-API-Key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"template_id\": \"${TEMPLATE_ID}\"
}"
Error Handling
Copy
import requests
import time
API_KEY = "pk_your_api_key_here"
BASE_URL = "https://poe.poesius.com/api/v1"
def generate_with_error_handling(document_path, instructions, num_slides):
try:
# Generate
with open(document_path, 'rb') as f:
response = requests.post(
f"{BASE_URL}/slides/generate-from-doc",
headers={'X-API-Key': API_KEY},
files={'document': f},
data={
'instructions': instructions,
'num_slides': num_slides
},
timeout=30
)
response.raise_for_status()
result = response.json()
presentation_id = result['presentation_id']
# Poll with timeout
max_wait = 300 # 5 minutes
start_time = time.time()
while time.time() - start_time < max_wait:
response = requests.get(
f"{BASE_URL}/presentations/{presentation_id}",
headers={'X-API-Key': API_KEY}
)
response.raise_for_status()
data = response.json()
if data['status'] == 'completed':
return data
elif data['status'] == 'failed':
raise Exception(f"Generation failed: {data.get('error')}")
time.sleep(5)
raise TimeoutError("Presentation generation timed out")
except requests.exceptions.RequestException as e:
print(f"Request error: {e}")
raise
except Exception as e:
print(f"Error: {e}")
raise
API Overview
Learn more about the REST API
MCP Examples
See MCP code examples

