Build an AI Essay Writer with AI Pass SDK
Build an AI Essay Writer with AI Pass SDK
Want to add AI-powered essay writing to your app or website? This friendly walkthrough shows you how to build a simple essay writer with the AI Pass SDK — from signing up to a working tool you can drop into any page.
What You'll Build
A lightweight web app where users type a topic, pick a style, and get a full essay. Authentication is handled by AI Pass (so you don’t need to build your own), and you earn 50% commission on every API call they make.
Step 1: Create Your AI Pass Account
Head to aipass.one and create an account — don’t forget to verify your email.
Step 2: Create an OAuth2 Client
- Go to Developer Dashboard
- Navigate to OAuth2 Clients
- Click Create Client
- Copy your Client ID (looks like
client_ODyf..., NOT your app slug)
Save that Client ID — AI Pass uses it to track API usage and credit your commission.
Step 3: Set Up the SDK
Add the AI Pass SDK to your HTML:
<script src="https://aipass.one/aipass-sdk.js"></script>
<script>
AiPass.initialize({
clientId: 'YOUR_CLIENT_ID',
requireLogin: true
});
</script>
Using requireLogin: true will show a login screen automatically, so you don't need to build a custom auth UI.
Step 4: Build the Essay Generator
Here’s a simple function you can plug into your page to request an essay from the SDK:
async function generateEssay() {
const topic = document.getElementById('topic').value;
const style = document.getElementById('style').value;
document.getElementById('result').innerText = 'Writing...';
const r = await AiPass.generateCompletion({
model: 'gpt-5-mini',
messages: [
{ role: 'system', content: `Write a well-structured ${style} essay. Include an introduction, body paragraphs, and conclusion.` },
{ role: 'user', content: topic }
]
});
document.getElementById('result').innerText = r.choices[0].message.content;
}
Step 5: Embed Anywhere
You’ve got two easy options:
Option A: Self-host — Put this HTML on your own server, GitHub Pages, Netlify, or Vercel. The SDK takes care of billing and auth for you.
Option B: Embed via iframe — If your app is on AI Pass, click the </> button (bottom-right) to grab an iframe embed code and drop it into any website.
How You Earn Money
Every time someone generates an essay in your app, AI Pass handles the API call and you receive 50% commission. There’s no invoicing or payment processing for you — users pay AI Pass directly, and you get your share.
Full Working Example
<!DOCTYPE html>
<html>
<head>
<title>AI Essay Writer</title>
<script src="https://aipass.one/aipass-sdk.js"></script>
</head>
<body>
<h1>AI Essay Writer</h1>
<textarea id="topic" rows="3" placeholder="Enter your essay topic..."></textarea>
<br>
<select id="style">
<option value="academic">Academic</option>
<option value="casual">Casual</option>
<option value="persuasive">Persuasive</option>
<option value="narrative">Narrative</option>
</select>
<select id="length">
<option value="short (200 words)">Short</option>
<option value="medium (500 words)">Medium</option>
<option value="long (1000 words)">Long</option>
</select>
<button onclick="generateEssay()">Generate Essay</button>
<div id="result" style="white-space: pre-wrap; margin-top: 20px;"></div>
<script>
AiPass.initialize({ clientId: 'YOUR_CLIENT_ID', requireLogin: true });
async function generateEssay() {
const topic = document.getElementById('topic').value;
const style = document.getElementById('style').value;
const length = document.getElementById('length').value;
document.getElementById('result').innerText = 'Writing your essay...';
try {
const r = await AiPass.generateCompletion({
model: 'gpt-5-mini',
messages: [
{ role: 'system', content: `Write a well-structured ${style} essay, approximately ${length}. Include introduction, body paragraphs with clear arguments, and conclusion.` },
{ role: 'user', content: topic }
]
});
document.getElementById('result').innerText = r.choices[0].message.content;
} catch(e) {
document.getElementById('result').innerText = 'Error: ' + e.message;
}
}
</script>
</body>
</html>
Next Steps
- Try the AI Essay Writer to see it in action
- AI Essay Writer Skill for Agents — API-first approach
- AI Essay Writer Guide — user-facing tutorial
Build with the AI Pass SDK. Users pay, you earn. No API keys to manage.