跳到主要內容

發表文章

目前顯示的是 3月, 2024的文章

使用 Google Gemini API 快速建置自己的 Flutter App

在 2024/02/21,Flutter Team 釋出了 Google Generative AI 這個 SDK,這個 SDK 大幅簡化了 Google Gemini API 呼叫的過程。讓 Flutter 或 Dart 開發者,只要在幾行的程式碼內,就能完成 Google Gemini API 的實作;這我們只要專注在 Flutter 的開發即可。 不囉嗦!我們直接來看怎麼使用! 在導入 Gemini API SDK 後,讓我們可以用這短短的幾行程式碼,便能獲得 Gemini API 的結果。 我們先來疏理一下需要準備的步驟 取得 API Key Flutter 專案設定 SDK 自由開發~ 1. 取得 API Key 1.1 Google AI Studio 首先,我們需要到 Google AI Studio  取得 API Key, 如下圖,進到 Google Ai Studio 平臺中的  Get Api Key   頁面,可以看到 Create API Key  的按鈕 1.2 Create API Key 選擇我們 Google Cloud 上的 projects,再點擊下方的 Create API key in existing project   等待一下,就能看到如下圖一樣,可以被複製的 API Key ...