google-gemini/generative-ai-dart
Fork: 115 Star: 571 (更新于 2024-12-01 03:49:15)
license: Apache-2.0
Language: Dart .
The official Dart library for the Google Gemini API
最后发布版本: google_generative_ai-v0.4.5 ( 2024-08-28 05:03:06)
Google Generative AI SDK for Dart
The Google AI Dart SDK is the easiest way for Dart developers to build with the Gemini API. The Gemini API gives you access to Gemini models created by Google DeepMind. Gemini models are built from the ground up to be multimodal, so you can reason seamlessly across text, images, and code.
[!CAUTION] Using the Google AI SDK for Dart (Flutter) to call the Google AI Gemini API directly from your app is recommended for prototyping only. If you plan to enable billing, we strongly recommend that you use the SDK to call the Google AI Gemini API only server-side to keep your API key safe. You risk potentially exposing your API key to malicious actors if you embed your API key directly in your mobile or web app or fetch it remotely at runtime.
Get started with the Gemini API
Getting Started
- Go to Google AI Studio.
- Login with your Google account.
- Create an API key. Note that in Europe the free tier is not available.
- Try a Dart CLI sample or the Flutter sample app.
- For detailed instructions, try the Dart SDK tutorial on ai.google.dev.
Usage example
See the Gemini API Cookbook or ai.google.dev for complete code.
- Add a dependency on the
package:google_generative_ai
package via:
dart pub add google_generative_ai
or:
flutter pub add google_generative_ai
- Initialize the API client
final model = GenerativeModel(model: 'gemini-1.5-flash-latest', apiKey: apiKey);
- Call the API to run a prompt
final prompt = 'Do these look store-bought or homemade?';
final imageBytes = await File('cookie.png').readAsBytes();
final content = [
Content.multi([
TextPart(prompt),
DataPart('image/png', imageBytes),
])
];
final response = await model.generateContent(content);
print(response.text);
Documentation
See the Gemini API Cookbook or ai.google.dev for complete documentation.
Contributing
See Contributing for more information on contributing to the Generative AI SDK for Dart.
License
The contents of this repository are licensed under the Apache License, version 2.0.
最近版本更新:(数据更新于 2024-09-16 21:04:53)
2024-08-28 05:03:06 google_generative_ai-v0.4.5
2024-05-31 00:35:15 google_generative_ai-v0.4.2
2024-05-24 05:49:30 google_generative_ai-v0.4.1
2024-05-11 06:33:34 google_generative_ai-v0.4.0
2024-05-07 08:49:14 google_generative_ai-v0.3.3
2024-04-27 08:39:28 google_generative_ai-v0.3.2
2024-04-19 05:05:53 google_generative_ai-v0.3.1
2024-02-23 07:48:12 google_generative_ai-v0.2.1
主题(topics):
dart, gemini, gemini-api
google-gemini/generative-ai-dart同语言 Dart最近更新仓库
2024-12-19 13:46:32 3003h/Eros-FE
2024-12-17 11:45:14 KaringX/karing
2024-12-14 22:23:30 guozhigq/pilipala
2024-12-09 02:47:22 KRTirtho/spotube
2024-12-09 00:51:26 chen08209/FlClash
2024-12-02 20:28:43 xiaoyaocz/dart_simple_live