namespace MS.Microservice.AI.Core; /// Options for AI request rate limiting. public sealed class AIRateLimitingOptions { /// Configuration section name under AI. public const string SectionName = "RateLimiting"; /// Whether the built-in fixed-window limiter is enabled. public bool Enabled { get; set; } /// Maximum requests per provider/model window. null means no built-in limit. public int? RequestsPerWindow { get; set; } /// Window duration in seconds. public int WindowSeconds { get; set; } = 60; } /// Options for AI provider circuit breaking. public sealed class AICircuitBreakerOptions { /// Configuration section name under AI. public const string SectionName = "CircuitBreaker"; /// Whether the built-in in-memory circuit breaker is enabled. public bool Enabled { get; set; } /// Consecutive failure threshold before opening the circuit. public int FailureThreshold { get; set; } = 5; /// How long the circuit remains open, in seconds. public int BreakDurationSeconds { get; set; } = 30; } /// Options for AI log sanitization. public sealed class AILogSanitizerOptions { /// Configuration section name under AI. public const string SectionName = "LogSanitizer"; /// Replacement text used for redacted values. public string RedactionText { get; set; } = "[REDACTED]"; /// Case-insensitive field names that should be redacted in metadata and simple text payloads. public ISet SensitiveFields { get; } = new HashSet(StringComparer.OrdinalIgnoreCase) { "api_key", "apikey", "apiKey", "authorization", "access_token", "token", "secret", "password", "prompt", "response", }; } /// Options for AI secret lookup. public sealed class AISecretProviderOptions { /// Configuration section name under AI. public const string SectionName = "SecretProvider"; /// Whether environment variables are preferred over configuration values. public bool PreferEnvironment { get; set; } = true; /// Environment variable prefix used for derived provider API key names. public string EnvironmentVariablePrefix { get; set; } = "AI__PROVIDERS__"; } /// Payload limit options by AI capability. public sealed class AIPayloadLimitOptions { /// Configuration section name under AI. public const string SectionName = "PayloadLimits"; /// Maximum combined chat message characters for non-streaming requests. public int MaxChatCharacters { get; set; } = 200_000; /// Maximum combined chat message characters for streaming requests. public int MaxStreamingChatCharacters { get; set; } = 200_000; /// Maximum text characters for text/audio text inputs. public int MaxTextCharacters { get; set; } = 100_000; /// Maximum audio request bytes. public long MaxAudioBytes { get; set; } = 25L * 1024 * 1024; /// Maximum image prompt characters. public int MaxImagePromptCharacters { get; set; } = 20_000; /// Maximum source image bytes for image edit requests. public long MaxImageBytes { get; set; } = 20L * 1024 * 1024; /// Maximum mask image bytes for image edit requests. public long MaxImageMaskBytes { get; set; } = 20L * 1024 * 1024; } /// Options for AI cost accounting hooks. public sealed class AICostAccountingOptions { /// Configuration section name under AI. public const string SectionName = "CostAccounting"; /// Whether the cost reporter hook is invoked by routing clients. public bool Enabled { get; set; } = true; }