From b7e27fbd29de1f4beaa4ce1ca28646edb194968f Mon Sep 17 00:00:00 2001 From: Guillaume Bernos Date: Fri, 10 Jul 2026 16:46:02 +0200 Subject: [PATCH] feat(ai): add a list of the MIME types supported by AI Logic --- .../firebase_ai/lib/firebase_ai.dart | 1 + .../firebase_ai/lib/src/mime_types.dart | 69 +++++++++++++++++++ .../firebase_ai/test/mime_types_test.dart | 38 ++++++++++ 3 files changed, 108 insertions(+) create mode 100644 packages/firebase_ai/firebase_ai/lib/src/mime_types.dart create mode 100644 packages/firebase_ai/firebase_ai/test/mime_types_test.dart diff --git a/packages/firebase_ai/firebase_ai/lib/firebase_ai.dart b/packages/firebase_ai/firebase_ai/lib/firebase_ai.dart index 06eeaaa1195f..a5f786321f54 100644 --- a/packages/firebase_ai/firebase_ai/lib/firebase_ai.dart +++ b/packages/firebase_ai/firebase_ai/lib/firebase_ai.dart @@ -118,6 +118,7 @@ export 'src/live_api.dart' SlidingWindow, Transcription; export 'src/live_session.dart' show LiveSession; +export 'src/mime_types.dart' show FirebaseAIMimeTypes; export 'src/schema.dart' show JSONSchema, Schema, SchemaType; export 'src/server_template/template_chat.dart' show TemplateChatSession, StartTemplateChatExtension; diff --git a/packages/firebase_ai/firebase_ai/lib/src/mime_types.dart b/packages/firebase_ai/firebase_ai/lib/src/mime_types.dart new file mode 100644 index 000000000000..4a375a78fbf8 --- /dev/null +++ b/packages/firebase_ai/firebase_ai/lib/src/mime_types.dart @@ -0,0 +1,69 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/// MIME types supported by Gemini multimodal models. +/// +/// Model capabilities can vary. Check the +/// [Firebase AI Logic documentation](https://firebase.google.com/docs/ai-logic) +/// before relying on a MIME type for a specific model. +abstract final class FirebaseAIMimeTypes { + /// Supported image MIME types. + static const List image = [ + 'image/png', + 'image/jpeg', + 'image/webp', + ]; + + /// Supported video MIME types. + static const List video = [ + 'video/x-flv', + 'video/quicktime', + 'video/mpeg', + 'video/mpegps', + 'video/mpg', + 'video/mp4', + 'video/webm', + 'video/wmv', + 'video/3gpp', + ]; + + /// Supported audio MIME types. + static const List audio = [ + 'audio/aac', + 'audio/flac', + 'audio/mp3', + 'audio/m4a', + 'audio/mpeg', + 'audio/mpga', + 'audio/mp4', + 'audio/opus', + 'audio/pcm', + 'audio/wav', + 'audio/webm', + ]; + + /// Supported document MIME types. + static const List document = [ + 'application/pdf', + 'text/plain', + ]; + + /// All supported multimodal MIME types. + static const List all = [ + ...image, + ...video, + ...audio, + ...document, + ]; +} diff --git a/packages/firebase_ai/firebase_ai/test/mime_types_test.dart b/packages/firebase_ai/firebase_ai/test/mime_types_test.dart new file mode 100644 index 000000000000..e43119c89858 --- /dev/null +++ b/packages/firebase_ai/firebase_ai/test/mime_types_test.dart @@ -0,0 +1,38 @@ +// Copyright 2026 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import 'package:firebase_ai/firebase_ai.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + test('exposes supported MIME types by media category', () { + expect( + FirebaseAIMimeTypes.image, + const ['image/png', 'image/jpeg', 'image/webp'], + ); + expect( + FirebaseAIMimeTypes.document, + const ['application/pdf', 'text/plain'], + ); + expect( + FirebaseAIMimeTypes.all, + containsAll([ + ...FirebaseAIMimeTypes.image, + ...FirebaseAIMimeTypes.video, + ...FirebaseAIMimeTypes.audio, + ...FirebaseAIMimeTypes.document, + ]), + ); + }); +}