これはNodejsで動作する、Gemini APIを使用した翻訳クライアントです。 API KeyはGoogle Cloud Platformで取得できます。
- Node.js v18以上
- npm v8以上
npm install @kotob/translateimport { Kotob } from "@kotob/translate";
const kotob = new Kotob({
key: 'YOUR_API_KEY',
});
(async () => {
const result = await kotob.translate('Hello, world!', 'en', 'ja');
console.log(result); // こんにちは、世界!(LLM翻訳ゆえに差異が出る可能性があります)
})();テキストを翻訳します。
text: 翻訳するテキストsourceLang: 元の言語コード(例: 'en', 指定されなかった場合、自動で推測されます)targetLang: 翻訳先の言語コード(例: 'ja', 指定されなかった場合、自動で推測されます)
APIの詳細なドキュメントはこちらをご覧ください。
ISC License