Tạo ứng dụng bằng Gemini API
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Mặc dù có thể sử dụng App Prototyping agent để tự động tạo một nguyên mẫu ứng dụng mới bằng Gemini API, nhưng bạn cũng có thể khởi chạy một canvas trống bằng Gemini Developer API chỉ bằng một lần nhấp vào nút. Bắt đầu sử dụng các mô hình AI tạo sinh mới nhất của Google trong ứng dụng của bạn bằng một mẫu có chứa tất cả cơ sở hạ tầng Gemini API mà bạn cần. Bạn chỉ cần thêm khoá Gemini API và bắt đầu viết mã!
Tạo một ứng dụng mới có Gemini API được tải sẵn
Truy cập vào mẫu Firebase Studio Gemini API trên trang tổng quan về mẫu và tạo bằng sức mạnh của AI.
- Mở mẫu Firebase Studio cho Gemini API từ trang tổng quan về mẫu Firebase Studio.
- Chọn ngôn ngữ và khung cho môi trường của bạn. Mẫu Gemini API trong Firebase Studio có sẵn bằng JavaScript (với Vite hoặc Genkit) và Python (notebook hoặc ứng dụng web với Flask), đồng thời sẽ sớm hỗ trợ thêm nhiều ngôn ngữ và khung.
- (Không bắt buộc) Nếu bạn muốn thêm khung LangChain vào ứng dụng, hãy chọn mục Sử dụng LangChain.
- Khi không gian làm việc của bạn tải, hãy mở tệp
main.js
hoặc main.py
rồi cập nhật biến API_KEY
bằng khoá Gemini API của bạn từ Google AI Studio.
- Kiểm thử ứng dụng cơ sở trong bảng xem trước trên web để xem Gemini API hoạt động và sửa đổi ứng dụng Gemini API mới cho phù hợp.
Thêm Gemini API vào một ứng dụng hiện có
Bạn cũng có thể thêm Gemini API vào ứng dụng hiện có ngay từ Firebase Studio.
Mở Firebase Studio.
Nhấp vào biểu tượng Firebase Studio trong ngăn điều hướng để mở ngăn Firebase Studio.
Mở rộng mục Google Integrations (Tích hợp với Google) rồi nhấp vào Thêm Gemini API.
Làm theo lời nhắc để xác thực tài khoản và thêm khoá Gemini API vào ứng dụng của bạn.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["While you can use [the App Prototyping agent](/docs/studio/get-started-ai)\nto automatically create a new app prototype with the Gemini API, you can\nalso launch a blank canvas with the\n[Gemini Developer API](https://ai.google.dev/) through one click of\na button. Start using the latest generative AI models from Google in your\napp with a template that includes all the Gemini API infrastructure you\nneed. All you need to do is add your\n[Gemini API key](https://ai.google.dev/tutorials/setup) and get coding!\n\nBuild a new app with the Gemini API pre-loaded\n\nAccess the Firebase Studio Gemini API template from the\ntemplates dashboard and build with the power of AI.\n\n1. Open the [Firebase Studio template for the Gemini API](https://studio.firebase.google.com//new/gemini) from the Firebase Studio template dashboard.\n2. Select the language and framework for your environment. The Gemini API template in Firebase Studio is available in JavaScript (with Vite or Genkit) and Python (notebook or web app with Flask), with more languages and frameworks coming soon.\n3. *(Optional)* If you want to add the [LangChain](https://www.langchain.com/) framework to your app, select the **Use LangChain** option.\n4. When your workspace loads, open the `main.js` or `main.py` file and update the `API_KEY` variable with your Gemini API key from [Google AI Studio](https://aistudio.google.com/app/apikey).\n5. Test the base app in the web preview panel to watch the Gemini API in action, and modify your new Gemini API app accordingly.\n\nAdd the Gemini API to an existing app\n\nYou can also add the Gemini API to your existing app directly from\nFirebase Studio.\n\n1. Open [Firebase Studio](https://studio.firebase.google.com/).\n\n2. Click the Firebase Studio icon from the navigation pane to open the\n Firebase Studio panel.\n\n3. Expand the **Google Integrations** section and click **Add Gemini API**.\n\n4. Follow the prompts to authenticate your account and add a Gemini API key\n to your app."]]