Spaces:
Sleeping
Sleeping
File size: 980 Bytes
cf476f3 |
1 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 |
export default async function handler(req, res) {
const response = await fetch("https://api.replicate.com/v1/predictions", {
method: "POST",
headers: {
Authorization: `Token ${process.env.REPLICATE_API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
// Pinned to a specific version of qwen-vl-chat
// See https://replicate.com/lucataco/qwen-vl-chat
version: process.env.MODEL_CODE,
// This is the text prompt that will be submitted by a form on the frontend
input: {
image: req.body.image,
prompt: req.body.prompt
},
}),
});
if (response.status !== 201) {
let error = await response.json();
res.statusCode = 500;
res.end(JSON.stringify({ detail: error.detail }));
return;
}
const prediction = await response.json();
res.statusCode = 201;
res.end(JSON.stringify(prediction));
} |