@@ -954,7 +954,8 @@ export const generateImage = async (
954
954
: ( runtime . getSetting ( "HEURIST_API_KEY" ) ??
955
955
runtime . getSetting ( "TOGETHER_API_KEY" ) ??
956
956
runtime . getSetting ( "FAL_API_KEY" ) ??
957
- runtime . getSetting ( "OPENAI_API_KEY" ) ) ;
957
+ runtime . getSetting ( "OPENAI_API_KEY" ) ??
958
+ runtime . getSetting ( "VENICE_API_KEY" ) ) ;
958
959
959
960
try {
960
961
if ( runtime . imageModelProvider === ModelProviderName . HEURIST ) {
@@ -1100,6 +1101,40 @@ export const generateImage = async (
1100
1101
} ) ;
1101
1102
1102
1103
const base64s = await Promise . all ( base64Promises ) ;
1104
+ return { success : true , data : base64s } ;
1105
+ } else if ( runtime . imageModelProvider === ModelProviderName . VENICE ) {
1106
+ const response = await fetch (
1107
+ "https://api.venice.ai/api/v1/image/generate" ,
1108
+ {
1109
+ method : "POST" ,
1110
+ headers : {
1111
+ Authorization : `Bearer ${ apiKey } ` ,
1112
+ "Content-Type" : "application/json" ,
1113
+ } ,
1114
+ body : JSON . stringify ( {
1115
+ model : data . modelId || "fluently-xl" ,
1116
+ prompt : data . prompt ,
1117
+ negative_prompt : data . negativePrompt ,
1118
+ width : data . width || 1024 ,
1119
+ height : data . height || 1024 ,
1120
+ steps : data . numIterations || 20 ,
1121
+ } ) ,
1122
+ }
1123
+ ) ;
1124
+
1125
+ const result = await response . json ( ) ;
1126
+
1127
+ if ( ! result . images || ! Array . isArray ( result . images ) ) {
1128
+ throw new Error ( "Invalid response format from Venice AI" ) ;
1129
+ }
1130
+
1131
+ const base64s = result . images . map ( ( base64String ) => {
1132
+ if ( ! base64String ) {
1133
+ throw new Error ( "Empty base64 string in Venice AI response" ) ;
1134
+ }
1135
+ return `data:image/png;base64,${ base64String } ` ;
1136
+ } ) ;
1137
+
1103
1138
return { success : true , data : base64s } ;
1104
1139
} else {
1105
1140
let targetSize = `${ data . width } x${ data . height } ` ;
0 commit comments