replicate / replicate-python

Python client for Replicate
https://replicate.com
Apache License 2.0
770 stars 222 forks source link

Call deployment API #357

Closed talkin-ai closed 1 month ago

talkin-ai commented 2 months ago

I have used the following code to call deployment, but failed. Would you tell me how to make it correct?

export default async function handler(req, res) { const response = await fetch("https://api.replicate.com/v1/deployments", { method: "POST", headers: { Authorization: Token ${process.env.REPLICATE_API_TOKEN}, "Content-Type": "application/json", }, body: JSON.stringify({ version: "#################", // This is the text prompt that will be submitted by a form on the frontend input: req.body, }), });

mattt commented 1 month ago

Hi @talkin-ai. I'd recommend using the JavaScript client library rather than fetch. Check out the replicate.deployments.create method.