Giter VIP home page Giter VIP logo

generative-ai-dart's Introduction

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

  1. Go to Google AI Studio.
  2. Login with your Google account.
  3. Create an API key. Note that in Europe the free tier is not available.
  4. Try a Dart CLI sample or the Flutter sample app.
  5. 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.

  1. Add a dependency on the package:google_generative_ai package via:
dart pub add google_generative_ai

or:

flutter pub add google_generative_ai
  1. Initialize the API client
final model = GenerativeModel(model: 'gemini-1.5-flash-latest', apiKey: apiKey);
  1. 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.

generative-ai-dart's People

Contributors

natebosch avatar devoncarew avatar dependabot[bot] avatar cynthiajoan avatar johnpryan avatar parlough avatar khanhnwin avatar lrhn avatar brianquinlan avatar davidmigloz avatar anderdobo avatar bwnyasse avatar giom-v avatar jakemac53 avatar loic-sharma avatar mit-mit avatar robertodrowaz avatar rodydavis avatar ryanwilson avatar ymodak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.