Next.js Discord

Discord Forum

https://gooey.ai/product-photo-background-generator/api/ how can I run this in next js?

Unanswered
Parson Russell Terrier posted this in #help-forum
Open in Discord
Avatar
Parson Russell TerrierOP
.

17 Replies

Avatar
French Lop
everything you need is in the docs (nodejs)
Avatar
Parson Russell TerrierOP
all the information is there but
Avatar
French Lop
but?
Avatar
Parson Russell TerrierOP
I can't do it
Avatar
Forest bachac
maybe try joining their discord?
Avatar
Parson Russell TerrierOP
Avatar
Roberto Duran
you can make a fetch to the replicate endpoint
for example:
const replicateResponse = await fetch("https://api.replicate.com/v1/predictions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: "Token " + process.env.REPLICATE_API_KEY,
    },
    body: JSON.stringify({
      version:
     "b1c17d148455c1fda435ababe9ab1e03bc0d917cc3cf4251916f22c45c83c7df",
      input: {
        image_path: [YOUR_IMAGE_PATH_OR]
      },
    }),
  });

  const jsonResponse = await replicateResponse.json();
  const endpointUrl = jsonResponse.urls.get;
just remember to run this in a server component, so you dont leak you replicate api token
Avatar
Parson Russell TerrierOP
can you write me the next js page using the form on the page
Avatar
Roberto Duran
ok let me find time for it
Avatar
Roberto Duran
@Parson Russell Terrier ok here is a working example https://github.com/roberto-duran/demo-replicate
and a example of the result
Image
@Parson Russell Terrier remember you need to create the .env file using the .env.example as base and add your replicate api key
Avatar
Parson Russell TerrierOP
uuuu thank you bro
Avatar
Parson Russell TerrierOP
Where did you get these prompts?
Avatar
Roberto Duran
in the replicate page is a demo tab and at the end of that tab are the examples
i use one of those
Avatar
Parson Russell TerrierOP
Dude, I want to start a startup with you
Avatar
Parson Russell TerrierOP
Dude, can you add file input to this?