How to Build an AI Affirmation Generator with AI Pass SDK
How to Build an AI Affirmation Generator with AI Pass SDK
Build a personalized affirmation generator that your users will love — and earn 50% commission on every API call they make.
What You'll Build
A web app where users describe their mood or challenge, pick a tone, and get AI-generated affirmations. Auth, billing, and payments are handled by the SDK.
Prerequisites
- Sign up at aipass.one
- Go to Developer Dashboard → OAuth2 Clients
- Create a new client → copy your Client ID
Step 1: Include the SDK
<!DOCTYPE html>
<html>
<head>
<title>AI Affirmation Generator</title>
<link href="https://aipass.one/aipass-ui.css" rel="stylesheet">
</head>
<body>
<script src="https://aipass.one/aipass-sdk.js"></script>
<script>
AiPass.initialize({
clientId: 'YOUR_CLIENT_ID',
requireLogin: true,
darkMode: true
});
</script>
</body>
</html>
requireLogin: true shows the auth screen automatically — no custom login UI needed.
Step 2: Build the UI
<div style="max-width: 600px; margin: 40px auto; padding: 20px;">
<h1>✨ Daily Affirmation Generator</h1>
<textarea id="situation" placeholder="What's on your mind? (e.g., nervous about a job interview)" rows="3" style="width:100%;"></textarea>
<select id="tone" style="width:100%; margin: 10px 0;">
<option value="gentle">Gentle & Nurturing</option>
<option value="empowering">Bold & Empowering</option>
<option value="spiritual">Spiritual & Mindful</option>
<option value="practical">Practical & Grounded</option>
</select>
<button onclick="generate()" style="width:100%; padding:12px; font-size:16px;">Generate Affirmations</button>
<div id="result" style="margin-top: 20px; white-space: pre-wrap;"></div>
</div>
Step 3: Add the AI Logic
async function generate() {
const situation = document.getElementById('situation').value;
const tone = document.getElementById('tone').value;
const resultDiv = document.getElementById('result');
resultDiv.textContent = 'Creating your affirmations...';
try {
const r = await AiPass.generateCompletion({
model: 'gpt-5-mini',
temperature: 1,
max_tokens: 16000,
messages: [
{
role: 'system',
content: `You are a compassionate affirmation coach. Generate 5 personalized affirmations based on the user's situation. Tone: ${tone}. Make them specific, grounded, and meaningful — not generic. Number each one.`
},
{ role: 'user', content: situation || 'General positivity and self-worth' }
]
});
resultDiv.textContent = r.choices[0].message.content;
} catch (err) {
resultDiv.textContent = 'Something went wrong. Please try again.';
}
}
Important: Always include temperature: 1 and max_tokens: 16000 — the SDK defaults don't work well with GPT-5.
Step 4: Deploy
Option A — Self-host anywhere: Upload your HTML to GitHub Pages, Netlify, Vercel, or your own server. The SDK handles all billing.
Option B — Publish on AI Pass: Submit to the AI Pass catalog and get a page at aipass.one/apps/your-app. Use the </> embed button to share as an iframe.
Revenue Model
Every time a user generates affirmations through your app, you earn 50% commission on the API cost. No payment infrastructure needed — AI Pass handles everything.
SDK Reference
AiPass.generateCompletion()→r.choices[0].message.contentAiPass.generateImage()→r.data[0].url- Full docs: aipass.one/docs/sdk/reference.html
See it live: AI Affirmation Generator · SDK Reference