GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - xszwow/Chrome2api: OpenAI-compatible local API wrapper for Chrome Gemini Nano / ChromeML

BranchesTags
Open more actions menu

Latest commit

 

History

11 Commits
11 Commits

Folders and files

NameName
Last commit message
Last commit date
data
data
 
 
docs
docs
 
 
model
model
 
 
reference
reference
 
 
runtime
runtime
 
 
scripts
scripts
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
NOTICE
NOTICE
 
 
README.md
README.md
 
 
README.zh-CN.md
README.zh-CN.md
 
 
THIRD_PARTY.md
THIRD_PARTY.md
 
 
关键数据.md
关键数据.md
 
 
启动API服务.ps1
启动API服务.ps1
 
 
运行裸Runner.ps1
运行裸Runner.ps1
 
 

Repository files navigation

Chrome2api

English | 简体中文

OpenAI-compatible local API wrapper for Chrome Gemini Nano / ChromeML.

This project is an experimental runner and API server around Chrome's on-device Gemini Nano runtime. It does not include Google model weights.

What This Is

Chrome2api provides:

  • A bare ChromeML runner source file.
  • A local OpenAI-compatible HTTP API server.
  • PowerShell wrappers for Windows.
  • Reference Chromium / Dawn headers used to understand the ABI.

The intended runtime chain is:

OpenAI-compatible client
  -> http://127.0.0.1:11435/v1/chat/completions
  -> runtime/chromeml_api_server.cjs
  -> runtime/ChromeMLBareRunner.exe
  -> optimization_guide_internal.dll
  -> webgpu_dawn.dll
  -> weights.bin

What Is Not Included

The following file is intentionally not included:

model/OptGuideOnDeviceModel/2025.8.8.1141/weights.bin

This file is not authored by this project. If you use this project locally, you must provide it yourself from a compatible local Chrome / Chrome component installation and comply with the relevant licenses and terms.

Do not upload this file to a public GitHub repository or redistribute it as part of this project. It is large, proprietary, and subject to Google / Chrome licensing terms.

Add Local Model File

After cloning, copy your local model file into this exact path:

Chrome2api/
  model/
    OptGuideOnDeviceModel/
      2025.8.8.1141/
        weights.bin

Typical source locations on a Windows machine with Chrome's on-device model component installed may look like:

%LOCALAPPDATA%\Google\Chrome\User Data\OptGuideOnDeviceModel\2025.8.8.1141\weights.bin

If the file is not there yet, trigger Chrome's built-in AI model download from a local page, then wait until the download reaches 100%.

$dir = "$env:TEMP\chrome2api-model-trigger"
New-Item -ItemType Directory -Force $dir | Out-Null
@'
<!doctype html>
<meta charset="utf-8">
<button id="run">Download Gemini Nano</button>
<pre id="log"></pre>
<script>
const log = (...args) => {
  document.getElementById("log").textContent += args.join(" ") + "\n";
};
document.getElementById("run").onclick = async () => {
  log("LanguageModel:", "LanguageModel" in self);
  if (!("LanguageModel" in self)) return;
  log("availability:", await LanguageModel.availability());
  await LanguageModel.create({
    monitor(m) {
      m.addEventListener("downloadprogress", e => {
        log("downloadprogress", e.loaded, e.total);
      });
    }
  });
  log("done");
};
</script>
'@ | Set-Content "$dir\index.html" -Encoding UTF8
Start-Process "C:\Program Files\Google\Chrome\Application\chrome.exe" "$dir\index.html"

After Chrome finishes, copy the downloaded model into this repository:

robocopy "$env:LOCALAPPDATA\Google\Chrome\User Data\OptGuideOnDeviceModel\2025.8.8.1141" `
  ".\model\OptGuideOnDeviceModel\2025.8.8.1141" /E

Expected Layout

After adding the local model file, the folder should look like:

Chrome2api/
  runtime/
    ChromeMLBareRunner.exe
    ChromeMLBareRunner.cpp
    chromeml_api_server.cjs
    optimization_guide_internal.dll
    webgpu_dawn.dll
  model/
    OptGuideOnDeviceModel/
      2025.8.8.1141/
        weights.bin
  docs/
    OPENAI_COMPAT_API.md
  running scripts...

Build Runner

The repository includes a prebuilt Windows runner. To rebuild it from source, use Zig's bundled clang on Windows:

.\scripts\build_runner.ps1

Or manually:

zig c++ -target x86_64-windows-gnu -std=c++17 -O2 -municode `
  -Iruntime runtime\ChromeMLBareRunner.cpp `
  -o runtime\ChromeMLBareRunner.exe `
  -lole32 -lwindowscodecs -lpsapi

Run Bare Runner

.\运行裸Runner.ps1 "Say exactly OK."

Multi-image input is supported by repeating -Image:

.\运行裸Runner.ps1 "Compare these images." `
  -Image C:\images\a.png `
  -Image C:\images\b.jpg

Run API Server

.\启动API服务.ps1 -HostAddress 127.0.0.1 -Port 11435

Then test:

curl.exe http://127.0.0.1:11435/v1/models
curl.exe --% -s http://127.0.0.1:11435/v1/chat/completions -H "Content-Type: application/json" -d "{\"model\":\"chrome-gemini-nano\",\"messages\":[{\"role\":\"user\",\"content\":\"Say exactly OK.\"}],\"max_tokens\":16}"

See docs/OPENAI_COMPAT_API.md for API details.

Current Capabilities

  • Text prompt.
  • Stateless multi-turn messages.
  • Image input through local file paths or file URLs.
  • Multiple image inputs at the runner layer.
  • One audio file input at the runner layer.
  • max_tokens mapped to output length.
  • temperature, top_k, and context-token options passed to the runner.
  • Non-streaming and simulated SSE streaming responses.

Compatibility Notes

Chrome2api is not Chrome Prompt API itself. It is a local compatibility layer around the lower ChromeML runtime. It does not implement browser permissions, Origin Trial logic, DOM input objects, or Chrome profile model registration.

Legal / Licensing

Project-authored source is released under the MIT License. Chromium and Dawn reference files remain under their original BSD-style licenses. Google model weights are not included and are not licensed by this project.

友情链接

  • LINUX.DO

About

OpenAI-compatible local API wrapper for Chrome Gemini Nano / ChromeML

Resources

Readme
MIT license
Activity

Stars

34 stars

Watchers

0 watching

Forks

6 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.