JavaScript SDK

Build powerful web applications with OAuth authentication, AI API calls, and beautiful UI components - all in one lightweight SDK.

Overview

The AI Pass JavaScript SDK provides everything you need to integrate AI capabilities into your web application:

OAuth2 + PKCE

Secure authentication with automatic token management

AI APIs

Chat, image generation, speech, and more

UI Components

Ready-to-use authentication buttons

Balance Tracking

Monitor usage and remaining credits

Installation

Add the SDK to your HTML page:

<!-- Include AI Pass SDK -->
<script src="https://aipass.one/aipass-sdk.js"></script>

<!-- Optional: Include UI Stylesheet -->
<link rel="stylesheet" href="https://aipass.one/aipass-ui.css">

Quick Start

1. Initialize the SDK

AiPass.initialize({
  clientId: 'your_client_id'
});

2. Add Authentication

<!-- Zero-config AI Pass button -->
<div data-aipass-button></div>

<!-- Or use custom login -->
<button onclick="login()">Sign in with AI Pass</button>

<script>
async function login() {
  await AiPass.login();
  console.log('Logged in!');
}
</script>

3. Make AI API Calls

const result = await AiPass.generateCompletion({
  prompt: 'Explain quantum computing',
  model: 'gemini/gemini-2.5-flash-lite',
  maxTokens: 500
});

console.log(result.choices[0].message.content);

Next Steps

Explore our comprehensive documentation and examples:

Interactive Quick Start Full API Reference Code Examples Developer Dashboard