* prepare monorepo and move client to its package * create nx workspace * workspace cleanup and updates * upgrade nx workspace and fix client package * add basic codegen logic * first working build script * update nextjs app * update generated code * add koldstart core and client foundation * add basic fetch implementation to client * add stable diffusion example * remove local output image * remove keys * remove more keys * update client usage and samples * remove grpc client code and dependencies * rename base package * remove core package * continue package refactor * rename koldstart apis * refactor main function run api * add listen function stub * removed more koldstart references * build workflow added * minor doc updates - trigger workflow * nx workflow action
30 lines
595 B
TypeScript
30 lines
595 B
TypeScript
import * as fal from '@fal/serverless-client';
|
|
|
|
export type GenerateImageInput = {
|
|
prompt: string;
|
|
};
|
|
|
|
type ImageType = 'gif' | 'png' | 'jpg' | 'jpeg';
|
|
type ImageDataUri = `data:image/${ImageType};base64,${string}`;
|
|
|
|
fal.config({
|
|
credentials: {
|
|
userId: '',
|
|
keyId: '',
|
|
keySecret: '',
|
|
},
|
|
});
|
|
|
|
export async function generateImage(
|
|
input: GenerateImageInput
|
|
): Promise<ImageDataUri> {
|
|
const result = await fal.run(
|
|
'a51c0ca0-9011-4ff0-8dc1-2ac0b42a9fd0/generate',
|
|
{
|
|
input,
|
|
}
|
|
);
|
|
const data = result['raw_data'];
|
|
return `data:image/jpg;base64,${data}`;
|
|
}
|