402 Payment Required issue
Closed this issue · 2 comments
gobigandwin commented
I try to use a proxy server to call "POST https://api.replicate.com/v1/predictions" locally and got the error below. My billing on Replicate is set up correctly. There is no issue when I run the model on the website.
Error in callReplicateAPI: ApiError: Request to http://localhost:3001/api/predictions failed with status 402 Payment Required: {"title":"Billing required","detail":"You need to set up billing to run this model. Go to https://replicate.com/account/billing#billing to set it up. If you have recently set up billing, please wait a few minutes before trying again.","status":402}
gobigandwin commented
js code:
const replicate = new Replicate({
auth: 'XXXX',
baseUrl: 'http://localhost:3001/api' // Update this line with full URL
});
console.log("connected to Replicate APIs....")
const output = await replicate.run(
"xrunda/hello:104b4a39315349db50880757bc8c1c996c5309e3aa11286b0a3c84dab81fd440",
{
input: {
source: selectedVideo,
target: s3Url_img,
}
}
vite.config.js:
import { defineConfig } from 'vite';
export default defineConfig({
server: {
port: 3001,
cors: true,
proxy: {
'/api': {
target: 'https://api.replicate.com/v1',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
secure: true,
headers: {
'Authorization': `Token ${process.env.REPLICATE_API_TOKEN}`
}
}
}
},
build: {
rollupOptions: {
input: {
main: './index.html'
}
}
}
})
gobigandwin commented
I got it addressed. It should fill the header authorization here with the actual value.