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.
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
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.
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
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...
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
.\运行裸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
.\启动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.
- 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_tokensmapped to output length.temperature,top_k, and context-token options passed to the runner.- Non-streaming and simulated SSE streaming responses.
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.
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.