Developer integration
AI Pass Web SDK
Your first metered AI call in about five minutes.
1) Add the SDK
<!-- Include AI Pass UI Stylesheet (optional but recommended) --> <link rel="stylesheet" href="https://aipass.one/aipass-ui.css"> <!-- Include AI Pass SDK (UI components built-in!) --> <script src="https://aipass.one/aipass-sdk.js"></script>
The UI stylesheet is optional but provides beautiful, zero-config authentication button with balance display and automatic state management!
2) Initialize (clientId is required)
<script>
AiPass.initialize({
clientId: 'your_client_id',
});
</script>3) Add AI Pass Button (Zero Config!)
<!-- Just add this one line - everything works automatically! --> <div data-aipass-button></div>
The button automatically handles login/logout, balance display, and state changes. No JavaScript code needed!
Or use a custom button:
<button id="aipass-login">Sign in with AI Pass</button>
<p id="aipass-status" aria-live="polite"></p>
<script>
document.getElementById('aipass-login').addEventListener('click', async () => {
const status = document.getElementById('aipass-status');
try {
await AiPass.login();
status.textContent = 'Signed in';
} catch (e) {
status.textContent = 'Login failed: ' + e.message;
}
});
</script>4) Call your first completion
const result = await AiPass.generateCompletion({
prompt: 'Tell me a short joke about browsers',
model: 'gemini-2.5-flash-lite',
maxTokens: 120
});
console.log(result.choices[0].message.content);Decisions
Decision models return typed answers and probabilities for routing, triage, moderation, scoring, yes/no checks, or picking a tool. Use a chat model when you need generated text or an explanation.
const { data } = await AiPass.getModelCatalog({ type: 'decision', method: 'decisions' });
if (!data.length) throw new Error('No decision model available');
const result = await AiPass.decide({
model: data[0].id,
state: 'My integration is broken and I am unhappy.',
questions: {
team: { type: 'choice', instructions: 'Pick a team', criteria: { billing: 'Payments', technical: 'Bugs' } },
happy: { type: 'score', instructions: 'Rate happiness', criteria: ['Unhappy', 'Neutral', 'Happy'] },
angry: { type: 'noul', instructions: 'Is the customer angry?' }
},
timeout: 60000 // Optional; signal: controller.signal also supports cancellation
});
console.log(result.answers, result.usage);Discover models at runtime with type decision and method decisions. Batch questions against one state; use low confidence for LLM or human fallback. Decisions never stream. Jev 1.13 accepts text-only input, costs $0.042 per 1M input tokens with free output, and allows 64k tokens per request and 32k for state plus the longest question. See REST curl examples.
Done!
That's the entire flow. From here you can:
- Generate images, speech, or embeddings, or use
AiPass.decide()for typed decisions. - Open your user dashboard with
AiPass.openDashboard(). - Check balance with
AiPass.getUserBalance().
Bonus: Complete minimal page with UI Button
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://aipass.one/aipass-ui.css">
</head>
<body>
<!-- Zero-config AI Pass button -->
<div data-aipass-button></div>
<button id="ask" disabled>Ask AI</button>
<div id="out"></div>
<script src="https://aipass.one/aipass-sdk.js"></script>
<script>
AiPass.initialize({ clientId: 'your_client_id' });
// Enable Ask button when user logs in
document.addEventListener('aipass:login', () => {
document.getElementById('ask').disabled = false;
});
// Disable Ask button when user logs out
document.addEventListener('aipass:logout', () => {
document.getElementById('ask').disabled = true;
document.getElementById('out').textContent = '';
});
// Enable if already authenticated
if (AiPass.isAuthenticated()) {
document.getElementById('ask').disabled = false;
}
document.getElementById('ask').onclick = async () => {
const res = await AiPass.generateCompletion({
prompt: 'Tell me a short joke!',
model: 'gemini-2.5-flash-lite'
});
document.getElementById('out').textContent = res.choices[0].message.content;
};
</script>
</body>
</html>