Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
image_generation.ml1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63let endpoint = "/v1/images/generations" open Basic.Images let send_raw k (client : Client.t) ~prompt ?n ?(size = (`S1024_1024 : size)) ?(response_format = (`Url : response_format)) ?user () = let n = Json.to_field_opt "n" yojson_of_int n in let user = Json.to_field_opt "top_p" yojson_of_string user in let response_format' = response_format |> string_of_response_format |> yojson_of_string in let body = List.filter (fun (_, v) -> v <> `Null) [ "prompt", `String prompt ; "size", size |> string_of_size |> yojson_of_string ; "response_format", response_format' ; user ; n ] |> fun l -> Yojson.Safe.to_string (`Assoc l) in let headers = [ "content-type", "application/json" ; "Authorization", String.concat " " [ "Bearer"; client.api_key ] ] in let%lwt resp = Ezcurl_lwt.post ~client:client.c ~headers ~content:(`String body) ~url:(client.gen_url endpoint) ~params:[] () in k ~response_format ~size resp ;; let send = send_raw @@ fun ~response_format ~size:_ -> function | Ok { body; _ } -> let json = Yojson.Safe.from_string body in Lwt.return Json.( json |> member "data" |> to_list |> List.map @@ fun e -> ( response_format , e |> member (string_of_response_format response_format) |> to_string )) | Error (_code, e) -> Lwt.fail_with e ;;