AI
window.agentlet.ai gives direct access to an AI provider (OpenAI today) with support for text, images, and PDF documents.
Check availability
Section titled “Check availability”const isAvailable = window.agentlet.ai.isAvailable();Send a text prompt
Section titled “Send a text prompt”const response = await window.agentlet.ai.sendPrompt('Analyze this data and provide insights');sendPrompt resolves to the assistant’s raw text reply. It throws if no provider is configured.
Send a prompt with images
Section titled “Send a prompt with images”const images = [screenshotBase64, documentImage]; // Data URLs, http(s) URLs, or bare base64 stringsconst analysis = await window.agentlet.ai.sendPrompt('What do you see in these images?', images);Send a prompt with a PDF document
Section titled “Send a prompt with a PDF document”const fileInput = document.getElementById('pdfFile');
const pdfAnalysis = await window.agentlet.ai.sendPromptWithPDF( 'Analyze this PDF document and summarize the key points', fileInput.files[0], // File, ArrayBuffer, Uint8Array, or an http(s) URL string { pdfOptions: { scale: 1.5, // Higher resolution maxPages: 10, // Limit pages for efficiency format: 'image/png', }, showInConsole: true, // Display converted images in console (default true) });sendPromptWithPDF converts the PDF to images internally, then behaves like sendPrompt.
Convert a PDF to images without sending it to AI
Section titled “Convert a PDF to images without sending it to AI”const pdfImages = await window.agentlet.ai.convertPDFToImages(fileInput.files[0]);// Resolves to an array of base64 data URL image strings, one per pageStatus and providers
Section titled “Status and providers”const status = window.agentlet.ai.getStatus();console.log(status.currentProvider); // 'openai'console.log(status.available); // true or falseconsole.log(status.pdfSupport.available); // true or falseconsole.log(status.pdfSupport.capabilities.maxRecommendedPages); // 10
const providers = window.agentlet.ai.getAvailableProviders();window.agentlet.ai.setProvider('openai');Validate the current configuration against the provider, useful for a settings screen:
const result = await window.agentlet.ai.validateAPI();if (result.success) { console.log(result.details.model, result.details.responseTime);} else { console.error(result.error);}Configuring credentials
Section titled “Configuring credentials”AI credentials are read from environment variables managed by window.agentlet.env. See Environment variables for the full API.
window.agentlet.env.OPENAI_API_KEY = 'sk-...';window.agentlet.env.OPENAI_MODEL = 'gpt-4o-mini';window.agentlet.ai.refresh(); // Refresh after env changesDirect access to the manager
Section titled “Direct access to the manager”window.agentlet.ai.manager (also window.agentlet.aiManager) is the underlying AIManager instance, exposing the same methods plus getCurrentProvider().
Source: agentlet-core CLAUDE.md, API Quick Reference (“AI integration”), and src/types/public-api.d.ts at e3f78fa.