forked from mito-systems/sol-mem-gen
constants
This commit is contained in:
parent
2fafd17cdb
commit
f521fe4087
@ -10,6 +10,10 @@ fal.config({
|
|||||||
credentials: process.env.FAL_AI_KEY
|
credentials: process.env.FAL_AI_KEY
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Consistent image size for all generations
|
||||||
|
const IMAGE_WIDTH: number = 1024
|
||||||
|
const IMAGE_HEIGHT: number = 1024
|
||||||
|
|
||||||
export async function POST(req: NextRequest): Promise<NextResponse> {
|
export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||||
try {
|
try {
|
||||||
const { prompt, modelId } = await req.json()
|
const { prompt, modelId } = await req.json()
|
||||||
@ -27,6 +31,15 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
|||||||
const result = await fal.subscribe(modelId, {
|
const result = await fal.subscribe(modelId, {
|
||||||
input: {
|
input: {
|
||||||
prompt: prompt,
|
prompt: prompt,
|
||||||
|
image_size: {
|
||||||
|
width: IMAGE_WIDTH,
|
||||||
|
height: IMAGE_HEIGHT
|
||||||
|
},
|
||||||
|
// Additional parameters for consistent output
|
||||||
|
num_images: 1,
|
||||||
|
scheduler: "DDIM",
|
||||||
|
num_inference_steps: 50,
|
||||||
|
guidance_scale: 7.5
|
||||||
},
|
},
|
||||||
logs: true,
|
logs: true,
|
||||||
onQueueUpdate: (update) => {
|
onQueueUpdate: (update) => {
|
||||||
@ -38,11 +51,15 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
|||||||
|
|
||||||
console.log('Flux generation result:', result)
|
console.log('Flux generation result:', result)
|
||||||
|
|
||||||
if (!result.data?.images?.[0]?.url) {
|
// Extract the image URL from the response
|
||||||
|
const imageUrl = result.data?.images?.[0]?.url
|
||||||
|
|
||||||
|
if (!imageUrl) {
|
||||||
|
console.error('No image URL in response:', result)
|
||||||
throw new Error('No image URL in response')
|
throw new Error('No image URL in response')
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({ imageUrl: result.data.images[0].url })
|
return NextResponse.json({ imageUrl })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Flux generation error:', error)
|
console.error('Flux generation error:', error)
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
|
Loading…
Reference in New Issue
Block a user