yandex-cloud 2025.4.14

Generated gRPC clients for the Yandex Cloud API
Documentation
/// The text descriptions and weights that the model uses to generate an image.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Message {
    /// Text describing the image.
    #[prost(string, tag = "1")]
    pub text: ::prost::alloc::string::String,
    /// Message weight. Negative values indicate negative messages.
    #[prost(double, tag = "2")]
    pub weight: f64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AspectRatio {
    /// Weight of width in image.
    #[prost(int64, tag = "1")]
    pub width_ratio: i64,
    /// Weight of height in image.
    #[prost(int64, tag = "2")]
    pub height_ratio: i64,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImageGenerationOptions {
    /// The [MIME type](<https://en.wikipedia.org/wiki/Media_type>) of generated image format.
    /// For possible specifications, see \[documentation\](/docs/foundation-models/concepts).
    #[prost(string, tag = "1")]
    pub mime_type: ::prost::alloc::string::String,
    /// Seed for image generation. It serves as a starting point for image generation from noise.
    #[prost(int64, tag = "2")]
    pub seed: i64,
    /// Aspect ratio of generated image.
    #[prost(message, optional, tag = "3")]
    pub aspect_ratio: ::core::option::Option<AspectRatio>,
}
/// Request for the service to generate an image.
///
/// For examples of usage, see [step-by-step guide](/docs/foundation-models/operations/yandexart/request).
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImageGenerationRequest {
    /// The [model URI](/docs/foundation-models/concepts/yandexart/models) to be used for image generation.
    #[prost(string, tag = "1")]
    pub model_uri: ::prost::alloc::string::String,
    /// A list of messages representing the context for the image generation model.
    #[prost(message, repeated, tag = "2")]
    pub messages: ::prost::alloc::vec::Vec<Message>,
    /// Image generation options.
    #[prost(message, optional, tag = "3")]
    pub generation_options: ::core::option::Option<ImageGenerationOptions>,
}
/// Response containing generated image.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImageGenerationResponse {
    /// The image is serialized as an array of bytes encoded in \[Base64\](<https://en.wikipedia.org/wiki/Base64>).
    #[prost(bytes = "vec", tag = "1")]
    pub image: ::prost::alloc::vec::Vec<u8>,
    /// The model version changes with each new releases.
    #[prost(string, tag = "2")]
    pub model_version: ::prost::alloc::string::String,
}
/// Generated client implementations.
pub mod image_generation_async_service_client {
    #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
    use tonic::codegen::*;
    use tonic::codegen::http::Uri;
    /// Service for creating images based on a text description.
    #[derive(Debug, Clone)]
    pub struct ImageGenerationAsyncServiceClient<T> {
        inner: tonic::client::Grpc<T>,
    }
    impl ImageGenerationAsyncServiceClient<tonic::transport::Channel> {
        /// Attempt to create a new client by connecting to a given endpoint.
        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
        where
            D: TryInto<tonic::transport::Endpoint>,
            D::Error: Into<StdError>,
        {
            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
            Ok(Self::new(conn))
        }
    }
    impl<T> ImageGenerationAsyncServiceClient<T>
    where
        T: tonic::client::GrpcService<tonic::body::BoxBody>,
        T::Error: Into<StdError>,
        T::ResponseBody: Body<Data = Bytes> + Send + 'static,
        <T::ResponseBody as Body>::Error: Into<StdError> + Send,
    {
        pub fn new(inner: T) -> Self {
            let inner = tonic::client::Grpc::new(inner);
            Self { inner }
        }
        pub fn with_origin(inner: T, origin: Uri) -> Self {
            let inner = tonic::client::Grpc::with_origin(inner, origin);
            Self { inner }
        }
        pub fn with_interceptor<F>(
            inner: T,
            interceptor: F,
        ) -> ImageGenerationAsyncServiceClient<InterceptedService<T, F>>
        where
            F: tonic::service::Interceptor,
            T::ResponseBody: Default,
            T: tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
                Response = http::Response<
                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
                >,
            >,
            <T as tonic::codegen::Service<
                http::Request<tonic::body::BoxBody>,
            >>::Error: Into<StdError> + Send + Sync,
        {
            ImageGenerationAsyncServiceClient::new(
                InterceptedService::new(inner, interceptor),
            )
        }
        /// Compress requests with the given encoding.
        ///
        /// This requires the server to support it otherwise it might respond with an
        /// error.
        #[must_use]
        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.send_compressed(encoding);
            self
        }
        /// Enable decompressing responses.
        #[must_use]
        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
            self.inner = self.inner.accept_compressed(encoding);
            self
        }
        /// Limits the maximum size of a decoded message.
        ///
        /// Default: `4MB`
        #[must_use]
        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_decoding_message_size(limit);
            self
        }
        /// Limits the maximum size of an encoded message.
        ///
        /// Default: `usize::MAX`
        #[must_use]
        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
            self.inner = self.inner.max_encoding_message_size(limit);
            self
        }
        /// A method for generating an image based on a textual description.
        pub async fn generate(
            &mut self,
            request: impl tonic::IntoRequest<super::ImageGenerationRequest>,
        ) -> std::result::Result<
            tonic::Response<super::super::super::super::super::operation::Operation>,
            tonic::Status,
        > {
            self.inner
                .ready()
                .await
                .map_err(|e| {
                    tonic::Status::new(
                        tonic::Code::Unknown,
                        format!("Service was not ready: {}", e.into()),
                    )
                })?;
            let codec = tonic::codec::ProstCodec::default();
            let path = http::uri::PathAndQuery::from_static(
                "/yandex.cloud.ai.foundation_models.v1.image_generation.ImageGenerationAsyncService/Generate",
            );
            let mut req = request.into_request();
            req.extensions_mut()
                .insert(
                    GrpcMethod::new(
                        "yandex.cloud.ai.foundation_models.v1.image_generation.ImageGenerationAsyncService",
                        "Generate",
                    ),
                );
            self.inner.unary(req, path, codec).await
        }
    }
}