simple-chromium-ai  by kstonekuan

TypeScript SDK for Chrome's local LLM Prompt API

Created 9 months ago
256 stars

Top 98.5% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a lightweight TypeScript wrapper for Chrome's Local LLM Prompt API, targeting developers building browser extensions. It simplifies LLM integration by offering type-safe initialization, automatic error handling, and a streamlined API, enabling quicker development of AI-powered features within Chromium browsers.

How It Works

The library acts as a thin layer over Chrome's native AI Prompt API, abstracting away complex setup and session management. It enforces type safety through TypeScript, preventing incorrect API calls. Key features include automatic error handling, a simplified prompt function, and a Safe API variant that returns Result types for explicit error management, enhancing robustness and developer experience.

Quick Start & Requirements

  • Install: npm install simple-chromium-ai
  • Prerequisites:
    • Chrome 138+ or compatible Chromium browser.
    • Enable "Prompt API for Gemini Nano" in chrome://flags.
    • Update "Optimization Guide On Device Model" in chrome://components.
    • Requires ~4GB model download.
    • Must be called from a browser extension context.
  • Resources:

Highlighted Details

  • Type Safety: Enforces correct initialization and API usage via TypeScript.
  • Simplified API: Offers straightforward functions for common LLM tasks.
  • Safe API: Provides Result types for explicit, graceful error handling.
  • Session Management: Supports persistent sessions for context and automatic cleanup utilities (createSession, withSession).
  • Advanced Features: Includes token usage checks, structured output with response constraints (JSON schema), and cancellable prompts using AbortController.

Maintenance & Community

The README does not detail specific contributors, sponsorships, or community channels (e.g., Discord, Slack).

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive for commercial use and integration into closed-source projects.

Limitations & Caveats

This wrapper prioritizes simplicity and does not expose all native API capabilities, notably omitting support for streaming responses. Users requiring streaming functionality must use the native Chromium AI APIs directly. The setup involves enabling specific browser flags and a significant model download (~4GB).

Health Check
Last Commit

2 days ago

Responsiveness

Inactive

Pull Requests (30d)
16
Issues (30d)
0
Star History
3 stars in the last 30 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera), and
6 more.

prompt-engine by microsoft

0.1%
3k
NPM library for LLM prompt engineering
Created 3 years ago
Updated 3 years ago
Starred by Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), Kevin Hou Kevin Hou(Head of Product Engineering at Windsurf), and
6 more.

TypeChat by microsoft

0.1%
9k
Library for building natural language interfaces using types
Created 2 years ago
Updated 3 days ago
Feedback? Help us improve.