11#include <nlohmann/json.hpp>
85 std::string media_type = {},
90 std::string media_type,
95 std::string media_type = {},
100 std::string media_type,
101 JsonValue options = JsonValue::object());
105 std::string media_type = {},
106 std::string filename = {},
107 JsonValue options = JsonValue::object());
111 std::string media_type,
112 std::string filename = {},
113 JsonValue options = JsonValue::object());
129 [[nodiscard]] const std::
string& value() const noexcept;
132 [[nodiscard]] const std::
string& url() const noexcept;
135 [[nodiscard]] const std::vector<std::uint8_t>& bytes() const noexcept;
138 [[nodiscard]] const std::
string& media_type() const noexcept;
141 [[nodiscard]] const std::
string& filename() const noexcept;
144 [[nodiscard]] const std::
string& provider() const noexcept;
147 [[nodiscard]] const
JsonValue& options() const noexcept;
150 [[nodiscard]] const
JsonValue& provider_data() const noexcept;
159 std::vector<std::uint8_t> bytes_;
160 std::
string media_type_;
161 std::
string filename_;
162 std::
string provider_;
179 std::string raw_arguments{
"{}"};
182 bool arguments_valid{
true};
198 JsonValue{{
"type",
"object"}, {
"properties", JsonValue::object()}};
224 std::vector<ToolCall> tool_calls = {});
228 std::vector<ToolCall> tool_calls = {});
232 std::string tool_name,
234 bool is_error =
false);
238 std::string tool_name,
240 bool is_error =
false);
246 [[nodiscard]] const
Contents& contents() const noexcept;
249 [[nodiscard]] const std::vector<
ToolCall>& tool_calls() const noexcept;
252 [[nodiscard]] const std::
string& tool_call_id() const noexcept;
255 [[nodiscard]] const std::
string& tool_name() const noexcept;
258 [[nodiscard]]
bool is_tool_error() const noexcept;
261 [[nodiscard]] std::
string text() const;
264 [[nodiscard]] const
JsonValue& provider_metadata() const noexcept;
275 std::
string tool_call_id_;
276 std::
string tool_name_;
277 bool tool_error_{
false};
278 JsonValue provider_metadata_ = JsonValue::object();
284 bool text_input{
true};
287 bool text_output{
true};
290 bool image_input{
false};
293 bool image_output{
false};
296 bool audio_input{
false};
299 bool audio_output{
false};
302 bool file_input{
false};
305 bool file_output{
false};
311 bool parallel_tool_calls{
false};
329 std::size_t context_window{0};
413 std::size_t model_rounds{1};
416 std::size_t tool_calls{0};
423 bool requires_continuation{
false};
430class NEURALPLUS_API
Error :
public std::runtime_error {
432 using std::runtime_error::runtime_error;
466 std::string code = {},
467 std::string request_id = {});
473 [[nodiscard]]
int status() const noexcept;
476 [[nodiscard]] const std::
string& code() const noexcept;
479 [[nodiscard]] const std::
string& request_id() const noexcept;
485 std::
string request_id_;
489[[nodiscard]] NEURALPLUS_API const
char* to_string(
Provider provider) noexcept;
492[[nodiscard]] NEURALPLUS_API const
char* to_string(
Role role) noexcept;
495[[nodiscard]] NEURALPLUS_API const
char* to_string(
FinishReason reason) noexcept;
Invalid or missing configuration.
Definition types.hpp:436
One text, image, audio, file, or provider-extension part.
Definition types.hpp:78
static Content audio_url(std::string url, std::string media_type={}, JsonValue options=JsonValue::object())
Creates audio referenced by URL.
static Content file_url(std::string url, std::string media_type={}, std::string filename={}, JsonValue options=JsonValue::object())
Creates a file referenced by URL.
static Content text(std::string value)
Creates a UTF-8 text part.
ContentType type() const noexcept
Returns the normalized kind of this content part.
static Content image_bytes(std::vector< std::uint8_t > bytes, std::string media_type, JsonValue options=JsonValue::object())
Creates an inline image. The provider adapter performs base64 encoding.
static Content image_url(std::string url, std::string media_type={}, JsonValue options=JsonValue::object())
Creates an image referenced by URL.
static Content extension(std::string provider, JsonValue provider_data)
static Content audio_bytes(std::vector< std::uint8_t > bytes, std::string media_type, JsonValue options=JsonValue::object())
Creates inline audio.
static Content file_bytes(std::vector< std::uint8_t > bytes, std::string media_type, std::string filename={}, JsonValue options=JsonValue::object())
Creates an inline file.
Base error for SDK failures.
Definition types.hpp:430
The configured number of provider requests was exhausted.
Definition types.hpp:448
A valid conversation message with one normalized role.
Definition types.hpp:208
static Message user(Contents contents)
Creates a multimodal user message.
static Message user(std::string text)
Creates a text user message.
static Message assistant(std::string text, std::vector< ToolCall > tool_calls={})
Creates a text assistant message, optionally containing tool calls.
Role role() const noexcept
Returns the normalized role of this message.
std::vector< Content > Contents
Ordered content-part collection used by multimodal messages.
Definition types.hpp:211
static Message system(std::string text)
Creates a system message. Sessions normally use Session::set_system.
static Message tool(std::string call_id, std::string tool_name, Contents contents, bool is_error=false)
Creates a tool result message.
static Message assistant(Contents contents, std::vector< ToolCall > tool_calls={})
Creates a multimodal assistant message.
static Message tool_json(std::string call_id, std::string tool_name, JsonValue value, bool is_error=false)
Creates a JSON tool result serialized as one text content part.
A provider returned an unsuccessful or malformed response.
Definition types.hpp:460
Provider provider() const noexcept
Returns the provider that produced the error.
ProviderError(std::string message, Provider provider, int status, std::string code={}, std::string request_id={})
Creates an error with normalized provider and HTTP correlation details.
A Session was already being used by another generation.
Definition types.hpp:442
An HTTP transport could not complete a request.
Definition types.hpp:454
Immutable snapshot passed to one provider round.
Definition types.hpp:372
std::string run_id
Identifier shared by all rounds of one generate call.
Definition types.hpp:377
GenerateOptions options
Normalized and provider-specific call options.
Definition types.hpp:389
std::vector< ToolSpec > tools
Tools available for this round.
Definition types.hpp:386
std::optional< std::string > system_message
Provider-independent system instruction.
Definition types.hpp:380
std::string session_id
Stable session identifier.
Definition types.hpp:374
std::vector< Message > messages
Complete normalized transcript snapshot.
Definition types.hpp:383
Normalized response returned by both one provider round and the full tool loop.
Definition types.hpp:393
std::string provider_request_id
Provider request/response correlation identifier.
Definition types.hpp:407
TokenUsage usage
Per-round usage from generate_once or cumulative usage from generate.
Definition types.hpp:404
std::string provider_model
Exact model identifier reported by the provider.
Definition types.hpp:410
AIResponse(Message message)
Creates a normalized response around one assistant message.
Message message
Assistant message returned by the provider.
Definition types.hpp:398
Per-call generation settings shared by all providers.
Definition types.hpp:339
std::optional< std::size_t > max_output_tokens
Maximum generated tokens for this call.
Definition types.hpp:344
std::optional< double > temperature
Sampling temperature, when the provider/model accepts it.
Definition types.hpp:341
Model features used for early validation and feature discovery.
Definition types.hpp:282
Data-driven model description; no C++ subclass is needed per model name.
Definition types.hpp:315
ModelCapabilities capabilities
Discoverable features used for early validation.
Definition types.hpp:326
std::string display_name
Optional user-interface label.
Definition types.hpp:323
std::string id
Provider model identifier.
Definition types.hpp:320
std::optional< std::size_t > max_output_tokens
Model-profile output limit applied when a call does not override it.
Definition types.hpp:332
Normalized token counts. Providers may leave unavailable values empty.
Definition types.hpp:351
std::optional< std::size_t > cache_creation_input_tokens
Input tokens written to a provider cache, when reported separately.
Definition types.hpp:365
std::optional< std::size_t > reasoning_tokens
Reasoning/thinking tokens, when reported.
Definition types.hpp:368
std::optional< std::size_t > input_tokens
Total tokens consumed from input, including provider cache reads/writes.
Definition types.hpp:353
std::optional< std::size_t > cached_input_tokens
Cached portion of input tokens, when reported.
Definition types.hpp:362
std::optional< std::size_t > total_tokens
Provider-reported or safely calculated total.
Definition types.hpp:359
std::optional< std::size_t > output_tokens
Tokens generated as output.
Definition types.hpp:356
ContentSource
Storage or reference form of a content part.
Definition types.hpp:70
ContentType
Kind of a multimodal content part.
Definition types.hpp:61
Role
Conversation role of a message.
Definition types.hpp:42
nlohmann::json JsonValue
Definition types.hpp:26
Provider
Provider family associated with a model descriptor.
Definition types.hpp:33
FinishReason
Normalized reason why generation stopped.
Definition types.hpp:50