Send image and file inputs through the real OpenAI client.
#include "example_support.hpp"
#include <iostream>
#include <utility>
using namespace neuralplus;
using namespace neuralplus_examples;
namespace {
void usage() {
std::cout
<< "OpenAI image/file input using the real Responses API\n"
<< "Usage: neuralplus_openai_multimodal [options]\n"
<< " --image PATH Add an inline image\n"
<< " --file PATH Add an inline document or text file\n"
<< " --api-key KEY Override OPENAI_API_KEY\n"
<< " --model ID Override gpt-5.6-terra\n"
<< " --prompt TEXT Question about the supplied media\n"
<< " --help Show this message\n";
}
}
int main(int argc, const char* const* argv) {
try {
const Arguments arguments(
argc,
argv,
{"--image", "--file", "--api-key", "--model", "--prompt"});
if (arguments.help()) {
usage();
return 0;
}
if (!arguments.has("--image") && !arguments.has("--file")) {
throw std::invalid_argument(
"provide --image PATH, --file PATH, or both");
}
arguments.has("--model")
arguments.has("--image");
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("--file")) {
const std::string path = arguments.require("--file");
contents.push_back(Content::file_bytes(
read_bytes(path), media_type(path), filename(path)));
}
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 OpenAIConfig gpt_5_6_terra()
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
Model features used for early validation and feature discovery.
Definition types.hpp:282
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
Definition providers.hpp:24
std::optional< std::string > api_key
Explicit API key. When empty, OPENAI_API_KEY is read once.
Definition providers.hpp:32
ModelDescriptor model
Model ID, capabilities, limits, and data-driven provider options.
Definition providers.hpp:29