Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Dart client for Genkit: Call Genkit Flows from ...

Dart client for Genkit: Call Genkit Flows from Flutter/Dart

Avatar for Nozomi Koborinai (cobo)

Nozomi Koborinai (cobo)

July 06, 2025
Tweet

More Decks by Nozomi Koborinai (cobo)

Other Decks in Programming

Transcript

  1. Dart client for Genkit Call Genkit Flows from Flutter/Dart Nozomi

    Koborinai Google Cloud Partner Top Engineer (Serverless App Development) 2025
  2. What is ? A server-side framework for AI applications, built

    by the Google Firebase team Define and run AI Flows directly on the server Enhanced observability for AI workflows Optimized for building AI application backend logic
  3. Future<String> generateImage({required String description}) async { try { final response

    = await dio.post( 'https://your-genkit-endpoint.com/generateImage', data: { 'data': { 'imageDescription': description, }, }, ); if (response.statusCode == 200) { return response.data['result']['url'] as String; } throw Exception('Failed to generate image: ${response.statusCode}'); } on DioException catch (e) { throw Exception('Failed to generate image: ${e.message}'); } } Calling Genkit from Dart Previous Challenges Boilerplate for HTTP Requests and JSON (De)serialization Challenging Manual Implementation of Streaming (SSE) Steep Learning Curve for Genkit Server-Side Specifics
  4. Using the Dart client for Genkit // 1. Define the

    remote action for the Genkit endpoint, // specifying its URL and response type. final action = defineRemoteAction( url: 'https://your-genkit-endpoint.com/generateImage', fromResponse: (data) => MyOutput.fromJson(data), ); final input = MyInput(message: 'Hello Dart Genkit!', count: 10); try { // 2. Call the defined remote action. final output = await action(input: input); print('Flow Response: ${output.reply}, ${output.newCount}'); } catch (e) { print('Error calling flow: $e'); }
  5. Google I/O Extended 25 Proprietary & Confidential Key Features Type-Safe

    & Reusable Actions Built-in Streaming (Server-Sent Events) Support Genkit official client library