Build an AI Poem Generator with the AI Pass SDK
Build an AI Poem Generator with the AI Pass SDK
Want to add AI-powered poetry generation to your app or website? This tutorial walks you through building a poem generator using the AI Pass SDK — from zero to deployed.
What You'll Build
A web app where users pick a topic, style, and mood, then get an AI-generated poem. The SDK handles authentication, billing, and AI calls for you.
Prerequisites
- An AI Pass account
- An OAuth2 Client ID (from Developer Dashboard → OAuth2 Clients)
- Basic HTML/JS knowledge
Step 1: Get Your Client ID
- Sign up at aipass.one
- Go to Developer Dashboard → OAuth2 Clients
- Create a new client — copy the
client_id(looks likeclient_xxxxx)
Important: The Client ID comes from the OAuth2 Clients page, NOT from your app slug.
Step 2: Add the SDK
<script src="https://aipass.one/aipass-sdk.js"></script>
<script>
AiPass.initialize({
clientId: 'YOUR_CLIENT_ID', // From Developer Dashboard
appSlug: 'your-app-slug',
requireLogin: true,
darkMode: true
});
</script>
Setting requireLogin: true means the SDK handles the entire login flow — modal, OAuth, token refresh. You don't write any auth code.
Step 3: Generate Poems
async function generatePoem(topic, style, mood) {
const response = await AiPass.generateCompletion({
model: 'openai/gpt-4.1-mini',
messages: [
{
role: 'system',
content: `Write a ${style} poem with a ${mood} mood. Output ONLY the poem.`
},
{
role: 'user',
content: `Write a poem about: ${topic}`
}
]
});
return response.choices[0].message.content;
}
That's it. The SDK handles auth tokens, billing, and API routing.
Step 4: Deploy Anywhere
Your app works on any hosting — GitHub Pages, Netlify, Vercel, your own server. The SDK manages billing through AI Pass, so your users pay per use and you earn 50% commission on every API call.
You can also publish it on the AI Pass catalog to get discovered by users, and offer an embed/iframe option via the </> button.
Earn While You Build
Every time a user generates a poem through your app, you earn 50% of the API cost. Build once, earn passively.
SDK Reference
AiPass.initialize()— set up auth and billingAiPass.generateCompletion()— text generationAiPass.generateImage()— image generation- Full SDK: aipass.one/aipass-sdk.js