inference_gateway_sdk/ext/image_request.rs
1//! Ergonomics for the image-generation request.
2//!
3//! The spec now types `CreateImageRequest::quality` and `::size`
4//! (`CreateImageRequestQuality` and `ImageSize`), so the former hand-written
5//! enums are gone - use the generated types directly. Only the `Default` impl
6//! remains: typify cannot derive one for the enums in the schema set, so it is
7//! maintained here and mirrors `chat_request.rs` so callers set just the fields
8//! they care about.
9
10use std::num::NonZeroU64;
11
12use crate::generated::schemas::{CreateImageRequest, CreateImageRequestResponseFormat};
13
14impl Default for CreateImageRequest {
15 /// Mirrors the schema defaults: `n` = 1, `response_format` = `url`.
16 fn default() -> Self {
17 Self {
18 model: None,
19 n: NonZeroU64::MIN, // schema default: 1
20 prompt: String::new(),
21 quality: None,
22 response_format: CreateImageRequestResponseFormat::Url,
23 size: None,
24 }
25 }
26}
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31
32 #[test]
33 fn default_matches_schema_defaults() {
34 let req = CreateImageRequest::default();
35 assert_eq!(req.n, NonZeroU64::MIN);
36 assert_eq!(req.response_format, CreateImageRequestResponseFormat::Url);
37 assert!(req.quality.is_none());
38 }
39}