fal/endpoints/fal_ai/janus/
mod.rs

1#[allow(unused_imports)]
2use crate::prelude::*;
3#[allow(unused_imports)]
4use serde::{Deserialize, Serialize};
5#[allow(unused_imports)]
6use std::collections::HashMap;
7
8#[derive(Debug, Serialize, Deserialize, Default)]
9pub struct HTTPValidationError {
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub detail: Option<Vec<Option<ValidationError>>>,
12}
13
14#[derive(Debug, Serialize, Deserialize, Default)]
15pub struct Image {
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub content_type: Option<String>,
18    pub height: i64,
19    pub url: String,
20    pub width: i64,
21}
22
23#[derive(Debug, Serialize, Deserialize, Default)]
24pub struct ImageSize {
25    /// The height of the generated image.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub height: Option<i64>,
28    /// The width of the generated image.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub width: Option<i64>,
31}
32
33#[derive(Debug, Serialize, Deserialize, Default)]
34pub struct JanusInput {
35    /// Classifier Free Guidance scale - how closely to follow the prompt.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    pub cfg_weight: Option<f64>,
38    /// If set to true, the safety checker will be enabled.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub enable_safety_checker: Option<bool>,
41    /// The size of the generated image.
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub image_size: Option<ImageSizeProperty>,
44    /// Number of images to generate in parallel.
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub num_images: Option<i64>,
47    /// The prompt to generate an image from.
48    /// "beautiful girl, inside a house"
49    pub prompt: String,
50    /// Random seed for reproducible generation.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub seed: Option<SeedProperty>,
53    /// Controls randomness in the generation. Higher values make output more random.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub temperature: Option<f64>,
56}
57
58#[derive(Debug, Serialize, Deserialize)]
59pub struct Output {
60    /// Whether the generated images contain NSFW concepts.
61    pub has_nsfw_concepts: Vec<bool>,
62    /// The generated image files info.
63    pub images: Vec<Image>,
64    /// The prompt used for generating the image.
65    pub prompt: String,
66    /// Seed of the generated Image. It will be the same value of the one passed in the
67    /// input or the randomly generated that was used in case none was passed.
68    pub seed: i64,
69    pub timings: Timings,
70}
71
72#[derive(Debug, Serialize, Deserialize, Default)]
73pub struct ValidationError {
74    pub loc: Vec<serde_json::Value>,
75    pub msg: String,
76    #[serde(rename = "type")]
77    pub ty: String,
78}
79
80#[derive(Debug, Serialize, Deserialize, smart_default::SmartDefault)]
81#[allow(non_camel_case_types)]
82pub enum ImageSizeProperty {
83    #[default]
84    ImageSize(ImageSize),
85    #[serde(rename = "square_hd")]
86    SquareHd,
87    #[serde(rename = "square")]
88    Square,
89    #[serde(rename = "portrait_4_3")]
90    Portrait43,
91    #[serde(rename = "portrait_16_9")]
92    Portrait169,
93    #[serde(rename = "landscape_4_3")]
94    Landscape43,
95    #[serde(rename = "landscape_16_9")]
96    Landscape169,
97}
98
99#[derive(Debug, Serialize, Deserialize, smart_default::SmartDefault)]
100#[allow(non_camel_case_types)]
101pub enum SeedProperty {
102    #[default]
103    Integer(i64),
104    Null(serde_json::Value),
105}
106
107#[derive(Debug, Serialize, Deserialize, Default)]
108pub struct Timings {
109    #[serde(skip_serializing_if = "Option::is_none")]
110    #[serde(rename = "type")]
111    pub ty: Option<serde_json::Value>,
112}
113
114/// DeepSeek Janus-Pro
115///
116/// Category: text-to-image
117pub fn janus(params: JanusInput) -> FalRequest<JanusInput, Output> {
118    FalRequest::new("fal-ai/janus", params)
119}