#ai #generative-ai #fal

macro fal-derive

Macros for creating fal API endpoint functions

1 unstable release

new 0.1.0 Mar 9, 2025

#30 in #generative-ai


Used in fal

MIT/Apache

7KB
109 lines

Creates a custom endpoint function, compatible with the fal API.

use fal::prelude::*;
use serde::Deserialize;

#[derive(Deserialize)]
pub struct FalResponse {
  pub images: Vec<File>,
}

#[endpoint(endpoint="fal-ai/flux/dev")]
pub fn flux_dev(prompt: String) -> FalResponse {}

// This endpoint function can now be used to call the fal endpoint:
#[tokio::main]
async fn main() {
    let response = flux_dev("an horse riding an astronaut".to_owned())
    .send()
    .await
    .unwrap();

    println!("Generated image URL: {}", response.images[0].url);
}

Dependencies

~215–660KB
~16K SLoC