Send image, audio, video, and file inputs through the real Gemini client.
#include "example_support.hpp"
#include <iostream>
#include <utility>
using namespace neuralplus;
using namespace neuralplus_examples;
namespace {
void usage() {
std::cout
<< "Gemini image/audio/video/file input using real generateContent\n"
<< "Usage: neuralplus_gemini_multimodal [options]\n"
<< " --image PATH Add an inline image\n"
<< " --audio PATH Add inline audio\n"
<< " --video PATH Add an inline video file\n"
<< " --file PATH Add an inline PDF or text file\n"
<< " --api-key KEY Override GEMINI_API_KEY/GOOGLE_API_KEY\n"
<< " --model ID Override gemini-3.6-flash\n"
<< " --prompt TEXT Question about the supplied media\n"
<< " --help Show this message\n";
}
void add_file(const Arguments& arguments,
const std::string& argument,
if (!arguments.has(argument)) {
return;
}
const std::string path = arguments.require(argument);
contents.push_back(Content::file_bytes(
read_bytes(path), media_type(path), filename(path)));
}
}
int main(int argc, const char* const* argv) {
try {
const Arguments arguments(
argc,
argv,
{"--image",
"--audio",
"--video",
"--file",
"--api-key",
"--model",
"--prompt"});
if (arguments.help()) {
usage();
return 0;
}
if (!arguments.has("--image") &&
!arguments.has("--audio") &&
!arguments.has("--video") &&
!arguments.has("--file")) {
throw std::invalid_argument(
"provide --image, --audio, --video, or --file PATH");
}
arguments.has("--model")
arguments.has("--image");
arguments.has("--audio");
arguments.has("--video") || arguments.has("--file");
apply_api_key(arguments, config.
api_key);
contents.push_back(Content::text(arguments.value_or(
"--prompt", "Describe and summarize the supplied content.")));
if (arguments.has("--image")) {
const std::string path = arguments.require("--image");
contents.push_back(
Content::image_bytes(read_bytes(path), media_type(path)));
}
if (arguments.has("--audio")) {
const std::string path = arguments.require("--audio");
contents.push_back(
Content::audio_bytes(read_bytes(path), media_type(path)));
}
add_file(arguments, "--video", contents);
add_file(arguments, "--file", contents);
client->generate(Message::user(std::move(contents)));
return 0;
} catch (const std::exception& error) {
return print_exception(error);
}
}
std::string text() const
Concatenates text parts without discarding non-text parts from the message.
std::vector< Content > Contents
Ordered content-part collection used by multimodal messages.
Definition types.hpp:211
NEURALPLUS_API GeminiConfig gemini_3_6_flash()
NEURALPLUS_API std::unique_ptr< AIClient > make_client(OpenAIConfig config, const ClientOptions &options={})
Creates an OpenAI client. Credentials resolve as explicit value, environment, error.
Normalized response returned by both one provider round and the full tool loop.
Definition types.hpp:393
Message message
Assistant message returned by the provider.
Definition types.hpp:398
Definition providers.hpp:76
ModelDescriptor model
Model ID, capabilities, limits, and data-driven provider options.
Definition providers.hpp:81
std::optional< std::string > api_key
Explicit key, otherwise GEMINI_API_KEY then GOOGLE_API_KEY is read once.
Definition providers.hpp:84
Model features used for early validation and feature discovery.
Definition types.hpp:282
bool audio_input
Accepts at least one supported audio source.
Definition types.hpp:296
bool file_input
Accepts at least one supported file source.
Definition types.hpp:302
bool text_input
Accepts UTF-8 text input.
Definition types.hpp:284
bool image_input
Accepts at least one supported image source.
Definition types.hpp:290
bool text_output
Can return normalized text.
Definition types.hpp:287
ModelCapabilities capabilities
Discoverable features used for early validation.
Definition types.hpp:326