2025-11-13 18:13:16 +01:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
2025-09-03 10:08:04 +02:00
|
|
|
namespace AIStudio.Provider.OpenAI;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The request body for the Responses API.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Model">Which model to use.</param>
|
2026-09-04 15:48:07 +02:00
|
|
|
/// <param name="Input">The chat messages and Responses API input items.</param>
|
2025-09-03 10:08:04 +02:00
|
|
|
/// <param name="Stream">Whether to stream the response.</param>
|
|
|
|
|
/// <param name="Store">Whether to store the response on the server (usually OpenAI's infrastructure).</param>
|
2026-10-10 15:38:50 +02:00
|
|
|
/// <param name="Tools">The local function tools to use for the request.</param>
|
2025-09-03 10:08:04 +02:00
|
|
|
public record ResponsesAPIRequest(
|
|
|
|
|
string Model,
|
2026-09-04 15:48:07 +02:00
|
|
|
IList<object> Input,
|
2025-09-03 10:08:04 +02:00
|
|
|
bool Stream,
|
|
|
|
|
bool Store,
|
2026-09-04 15:48:07 +02:00
|
|
|
IList<object> Tools)
|
2025-09-03 10:08:04 +02:00
|
|
|
{
|
2026-11-03 07:59:30 +01:00
|
|
|
//
|
|
|
|
|
// The properties of the parameters, declared again to be settable. The source generation of System.Text.Json
|
|
|
|
|
// sets every init-only property while it creates the object, also one missing in the JSON, so its value from
|
|
|
|
|
// the parameterless constructor would get lost. Keep them first and in the order of the parameters, which is
|
|
|
|
|
// the order they get written in:
|
|
|
|
|
//
|
|
|
|
|
public string Model { get; set; } = Model;
|
|
|
|
|
public IList<object> Input { get; set; } = Input;
|
|
|
|
|
public bool Stream { get; set; } = Stream;
|
|
|
|
|
public bool Store { get; set; } = Store;
|
|
|
|
|
public IList<object> Tools { get; set; } = Tools;
|
|
|
|
|
|
2025-09-03 10:08:04 +02:00
|
|
|
public ResponsesAPIRequest() : this(string.Empty, [], true, false, [])
|
|
|
|
|
{
|
|
|
|
|
}
|
2026-11-03 07:59:30 +01:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Attention: The "required" modifier is not supported for [JsonExtensionData], and neither is init: the source
|
|
|
|
|
// generation of System.Text.Json refuses to write the request at all then.
|
|
|
|
|
//
|
2025-11-13 18:13:16 +01:00
|
|
|
[JsonExtensionData]
|
2026-11-03 07:59:30 +01:00
|
|
|
public IDictionary<string, object> AdditionalApiParameters { get; set; } = new Dictionary<string, object>();
|
2026-04-13 13:33:17 +02:00
|
|
|
}
|