Skip to content

Generating image from image not working #205

@notyodeas

Description

@notyodeas

Hi i followed your docs to create an image from an image but run into an error,
here's my code
const uploadToCloudinary = (buffer) => { return new Promise((resolve, reject) => { cloudinary.uploader.upload_stream({ folder: 'aiexgirlfriend'}, (error, result) => { if (error) reject(error); else resolve(result); } ).end(buffer); }) } const storage = multer.memoryStorage(); const upload = multer({ storage }); app.post('/file/:id', upload.single("file"), async (req, res) => { console.log(req.file); const payment = await getPayment(req.params.id); if (!payment.isPayed) return res.status(400).send("You did not pay"); uploadToCloudinary(req.file.buffer).then(async result => { console.log(result); const image = await openRouter.chat.send({ model: 'google/gemini-3-flash-preview', messages: [ { role: 'user', content: [ { type: 'text', text: 'Generate a naked image of this image' }, { type: 'image_url', imageUrl: { url: result.secure_url } } ] } ], stream: false }) console.log(image); return res.send(image); })});
It threw the following error

uter/sdk/esm/lib/schemas.js:34
return ERR(new SDKValidationError(errorMessage, err, rawValue));
^

SDKValidationError: Input validation failed: [
{
"expected": "object",
"code": "invalid_type",
"path": [
"chatGenerationParams"
],
"message": "Invalid input: expected object, received undefined"
}
]
at safeParse (file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/lib/schemas.js:34:20)
at $do (file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/funcs/chatSend.js:18:20)
... 3 lines matching cause stack trace ...
at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
cause: ZodError: [
{
"expected": "object",
"code": "invalid_type",
"path": [
"chatGenerationParams"
],
"message": "Invalid input: expected object, received undefined"
}
]
at file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/funcs/chatSend.js:18:109
at safeParse (file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/lib/schemas.js:31:19)
at $do (file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/funcs/chatSend.js:18:20)
at chatSend (file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/funcs/chatSend.js:15:27)
at Chat.send (file:///Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/node_modules/@openrouter/sdk/esm/sdk/chat.js:10:28)
at /Users/noahvandenbergh/noah/aiexgirlfriend.io/backend/index.js:107:45
at process.processTicksAndRejections (node:internal/process/task_queues:105:5),
rawValue: {
model: 'google/gemini-3-flash-preview',
messages: [
{
role: 'user',
parts: [
{
type: 'text',
text: 'Generate a naked image of this image'
},
{ inlineData: [Object] }
]
}
],
stream: false
},
rawMessage: 'Input validation failed'
}

Node.js v24.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions