on cjwbw/rembg: Invalid version or not permitted
Ebrahim-Ramadan opened this issue · 6 comments
says
ApiError: Request to https://api.replicate.com/v1/predictions failed with status 422 Unprocessable Entity: {"title":"Invalid version or not permitted","detail":"The specified version does not exist (or perhaps you don't have permission to use it?)","status":422}
on
this endpoint
// pages/api/run-model.js
import { NextResponse } from "next/server";
import Replicate from "replicate";
export async function POST(req, res) {
if (req.method !== "POST") {
return NextResponse.json({ error: 'req mehthod not allowed' }, { status: 405 });
}
try {
const { base64Image } = req.body; // Get image URL from the request body
console.log('process.env.REPLICATE_API_TOKEN', process.env.REPLICATE_API_TOKEN);
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN, // Your API token from the environment variable
});
const input = { image: base64Image };
// Run the model
const output = await replicate.run(
"cjwbw/rembg:fb8af171cfa1616ddcf1242c093f9c46bcada5ad4cf6f2fbe8b81b330ec5c003",
{ input }
);
console.log('output', output);
return NextResponse.json({ output }, { status: 200 });
} catch (error) {
console.error("Error running model:", error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}
however the version number of the rembg model is verified here, and the api_token is re-generated and valid too.
Hi @Ebrahim-Ramadan. You may get this error if you don't have billing set up for your account. Go to https://replicate.com/account/billing and setup a payment method and try again.
Hi @Ebrahim-Ramadan. You may get this error if you don't have billing set up for your account. Go to https://replicate.com/account/billing and setup a payment method and try again.
oooooookay
Hi @mattt, I'm currently experiencing this error too. Weirdly, this only happens when i try to replace my current API model (which is stable-diffusion-3). The latter runs just fine, so it's definitely not a problem with my Replicate setup or my code. Whenever i try to replace model with let's say for example fofr/flux-replicate-logo, or even bytedance/sdxl-lightning-4step , it throws this error and the prediction is not successful. Do you have any issues why this happens?
API Response: {"title":"Invalid version or not permitted","detail":"The specified version does not exist (or perhaps you don't have permission to use it?)","status":422}
i still get same error too, even my billing is activated, and i'm using the latest Version Model ID.
Also getting this error when I try to create a prediction withreplicate.predictions.create on black-forest-labs/flux-schnell, SDXL, and my own fine-tunes. I'm able to use the API normally with replicate.run, but this isn't great when generating multiple outputs.
Billing is enabled and a payment method has been added.