{"id":16354564,"url":"https://github.com/jeasonstudio/chrome-ai","last_synced_at":"2025-10-07T00:12:44.929Z","repository":{"id":244004484,"uuid":"814029681","full_name":"jeasonstudio/chrome-ai","owner":"jeasonstudio","description":"Vercel AI provider for Chrome built-in model (Gemini Nano)","archived":false,"fork":false,"pushed_at":"2024-09-09T02:05:20.000Z","size":287,"stargazers_count":266,"open_issues_count":3,"forks_count":22,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-12T01:35:39.673Z","etag":null,"topics":["chrome","gemini","gemini-nano","llm","vercel-ai-sdk"],"latest_commit_sha":null,"homepage":"https://try-chromeai.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeasonstudio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-12T07:53:57.000Z","updated_at":"2024-10-09T21:29:10.000Z","dependencies_parsed_at":"2024-06-12T13:02:38.951Z","dependency_job_id":"45767831-64a1-4023-99a4-23ed207d33a6","html_url":"https://github.com/jeasonstudio/chrome-ai","commit_stats":null,"previous_names":["jeasonstudio/chrome-ai"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeasonstudio%2Fchrome-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeasonstudio%2Fchrome-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeasonstudio%2Fchrome-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeasonstudio%2Fchrome-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeasonstudio","download_url":"https://codeload.github.com/jeasonstudio/chrome-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543595,"owners_count":20955865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","gemini","gemini-nano","llm","vercel-ai-sdk"],"created_at":"2024-10-11T01:35:36.081Z","updated_at":"2025-10-07T00:12:39.906Z","avatar_url":"https://github.com/jeasonstudio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\n\u003cimg src=\"https://mdn.alipayobjects.com/huamei_1hrimu/afts/img/A*OLMCRq2wg7cAAAAAAAAAAAAADp95AQ/original\" alt=\"chrome-ai\" width=\"200\"/\u003e\n\n\u003ch1\u003eChrome AI\u003c/h1\u003e\n\n[Vercel AI](https://sdk.vercel.ai/docs/introduction) provider for Chrome built-in model (Gemini Nano).\n\n[![NPM version][npm-image]][npm-url]\n[![NPM downloads][download-image]][download-url]\n[![Stargazers][stars-shield]][stars-url]\n[![MIT License][license-shield]][license-url]\n\n[![CI status][github-action-image]][github-action-url]\n[![codecov][codecov-image]][codecov-url]\n[![Follow Twitter][twitter-image]][twitter-url]\n\n[Report Bug](https://github.com/jeasonstudio/chrome-ai/issues/new) · [Pull Request](https://github.com/jeasonstudio/chrome-ai/compare)\n\n![](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/rainbow.png)\n\n[npm-image]: https://img.shields.io/npm/v/chrome-ai?style=for-the-badge\n[npm-url]: http://npmjs.org/package/chrome-ai\n[download-image]: https://img.shields.io/npm/dm/chrome-ai.svg?style=for-the-badge\n[download-url]: https://npmjs.org/package/chrome-ai\n[github-action-image]: https://img.shields.io/github/actions/workflow/status/jeasonstudio/chrome-ai/ci.yml?style=for-the-badge\n[github-action-url]: https://github.com/jeasonstudio/chrome-ai/actions?query=workflow=%22ci%22\n[codecov-image]: https://img.shields.io/codecov/c/github/jeasonstudio/chrome-ai/main.svg?style=for-the-badge\n[codecov-url]: https://codecov.io/gh/jeasonstudio/chrome-ai/branch/main\n[license-shield]: https://img.shields.io/github/license/jeasonstudio/chrome-ai.svg?style=for-the-badge\n[license-url]: https://github.com/jeasonstudio/chrome-ai/blob/main/LICENSE\n\n[stars-shield]: https://img.shields.io/github/stars/jeasonstudio/chrome-ai.svg?style=for-the-badge\n[stars-url]: https://github.com/jeasonstudio/chrome-ai/stargazers\n[issues-shield]: https://img.shields.io/github/issues/jeasonstudio/chrome-ai.svg?style=for-the-badge\n[issues-url]: https://github.com/jeasonstudio/chrome-ai/issues\n[twitter-image]: https://img.shields.io/twitter/follow/jeasonstudio?style=for-the-badge\u0026logo=x\n[twitter-url]: https://twitter.com/jeasonstudio\n\n\u003c/div\u003e\n\n\u003e ⚠️ Note:\n\u003e * This module is under development and may contain errors and frequent incompatible changes.\n\u003e * Chrome's implementation of [built-in AI with Gemini Nano](https://developer.chrome.com/docs/ai/built-in) is an experiment and will change as they test and address feedback.\n\u003e * If you've never heard of it before, [follow these steps](#enabling-ai-in-chrome) to turn on Chrome's built-in AI.\n\n## 📦 Installation\n\nThe ChromeAI provider is available in the `chrome-ai` module. You can install it with:\n\n```bash\nnpm install chrome-ai\n```\n\n## 🦄 Language Models\n\nThe `chromeai` provider instance is a function that you can invoke to create a language model:\n\n```ts\nimport { chromeai } from 'chrome-ai';\n\nconst model = chromeai();\n```\n\nIt automatically selects the correct model id. You can also pass additional settings in the second argument:\n\n```ts\nimport { chromeai } from 'chrome-ai';\n\nconst model = chromeai('text', {\n  // additional settings\n  temperature: 0.5,\n  topK: 5,\n});\n```\n\nYou can use the following optional settings to customize:\n\n- **modelId** `'text' (default: `'text'`)\n- **temperature** `number` (default: `0.8`)\n- **topK** `number` (default: `3`)\n\n## ⭐️ Embedding models\n\n```ts\nimport { chromeai } from 'chrome-ai';\nimport { embedMany, cosineSimilarity } from 'ai';\n\nconst { embeddings } = await embedMany({\n  model: chromeai('embedding'),\n  values: ['sunny day at the beach', 'rainy afternoon in the city'],\n});\n// [[1.9545, 0.0318...], [1.8015, 0.1504...]]\n\nconst similarity = cosineSimilarity(embeddings[0], embeddings[1]);\n// similarity: 0.9474937159037822\n```\n\n## 🎯 Examples\n\nYou can use Chrome built-in language models to generate text with the `generateText` or `streamText` function:\n\n```javascript\nimport { generateText } from 'ai';\nimport { chromeai } from 'chrome-ai';\n\nconst { text } = await generateText({\n  model: chromeai(),\n  prompt: 'Who are you?',\n});\n\nconsole.log(text); //  I am a large language model, trained by Google.\n```\n\n```javascript\nimport { streamText } from 'ai';\nimport { chromeai } from 'chrome-ai';\n\nconst { textStream } = await streamText({\n  model: chromeai(),\n  prompt: 'Who are you?',\n});\n\nlet result = '';\nfor await (const textPart of textStream) {\n  result += textPart;\n}\n\nconsole.log(result);\n//  I am a large language model, trained by Google.\n```\n\nChrome built-in language models can also be used in the `generateObject/streamObject` function:\n\n```javascript\nimport { generateObject } from 'ai';\nimport { chromeai } from 'chrome-ai';\nimport { z } from 'zod';\n\nconst { object } = await generateObject({\n  model: chromeai(),\n  schema: z.object({\n    recipe: z.object({\n      name: z.string(),\n      ingredients: z.array(\n        z.object({\n          name: z.string(),\n          amount: z.string(),\n        })\n      ),\n      steps: z.array(z.string()),\n    }),\n  }),\n  prompt: 'Generate a lasagna recipe.',\n});\n\nconsole.log(object);\n// { recipe: {...} }\n```\n\n```javascript\nimport { streamObject } from 'ai';\nimport { chromeai } from 'chrome-ai';\nimport { z } from 'zod';\n\nconst { partialObjectStream } = await streamObject({\n  model: chromeai(),\n  schema: z.object({\n    recipe: z.object({\n      name: z.string(),\n      ingredients: z.array(\n        z.object({\n          name: z.string(),\n          amount: z.string(),\n        })\n      ),\n      steps: z.array(z.string()),\n    }),\n  }),\n  prompt: 'Generate a lasagna recipe.',\n});\n\nfor await (const partialObject of result.partialObjectStream) {\n  console.log(JSON.stringify(partialObject, null, 2));\n  // { recipe: {...} }\n}\n```\n\n\u003e Due to model reasons, `toolCall/functionCall` are not supported. We are making an effort to implement these functions by prompt engineering.\n\n## Enabling AI in Chrome\n\nChrome built-in AI is a preview feature, you need to use chrome version 127 or greater, now in [dev](https://www.google.com/chrome/dev/?extra=devchannel) or [canary](https://www.google.com/chrome/canary/) channel, [may release on stable chanel at Jul 17, 2024](https://chromestatus.com/roadmap).\n\nAfter then, you should turn on these flags:\n* [chrome://flags/#prompt-api-for-gemini-nano](chrome://flags/#prompt-api-for-gemini-nano): `Enabled`\n* [chrome://flags/#optimization-guide-on-device-model](chrome://flags/#optimization-guide-on-device-model): `Enabled BypassPrefRequirement`\n* [chrome://components/](chrome://components/): Click `Optimization Guide On Device Model` to download the model.\n\nOr you can try using the experimental feature: `chrome-ai/polyfill`, to use `chrome-ai` in any browser that supports WebGPU and WebAssembly.\n\n```ts\nimport 'chrome-ai/polyfill';\n// or\nrequire('chrome-ai/polyfill');\n```\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=jeasonstudio/chrome-ai\u0026type=Date)](https://star-history.com/#jeasonstudio/chrome-ai\u0026Date)\n\n## License\n\n[MIT](LICENSE) License © 2024 [Jeason](https://github.com/jeasonstudio)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeasonstudio%2Fchrome-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeasonstudio%2Fchrome-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeasonstudio%2Fchrome-ai/lists"}