
Security News
crates.io Ships Security Tab and Tightens Publishing Controls
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.
node-replicate
Advanced tools
A NodeJS client for Replicate.
import replicate from "node-replicate"
const prediction = await replicate
.model(
"stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf",
)
.predict({
prompt: "an astronaut riding on a horse",
})
console.log(prediction.output)
// [ "https://replicate.delivery/pbxt/nSREat5H54rxGJo1kk2xLLG2fpr0NBE0HBD5L0jszLoy8oSIA/out-0.png" ]
Magic!
Replicate is an online platform for running generative AI models in the cloud. This package implements a lightweight client for their anonymous API, allowing you to run Stable Diffusion, CLIP and other state-of-the-art models with only a few lines of code. Those familiar with replicate-js should feel right at home 😊👌.
Install with npm:
npm i node-replicate
Like replicate-js, this package exports model, which can be used to access a particular model on Replicate. A model's identifier consists of a path (e.g. stability-ai/stable-diffusion) and a version (e.g. db21...e5bf) separated by a colon. You can obtain this information from a model's home page on Replicate.
const model = replicate.model("stability-ai/stable-diffusion:db21e45d3f7023abc2a46ee38a23973f6dce16bb082a930b0c49861f96d1e5bf")
Once you've obtained a model identifier, you can run the model using predict. This method takes in one or more parameters such as prompt. The specific parameters for a model can also be found on its home page (e.g. https://replicate.com/stability-ai/stable-diffusion/api).
const prediction = await model.predict({ prompt: "an astronaut riding on a horse" })
This will return a Prediction object containing the model's output, as well as other metadata. The output is a JavaScript object, typically an array, containing one or more results depending on how you queried the model. For instance, most image synthesis models return an array of image URLs.
To track a model's progress during inference, you can specify an onUpdate callback:
const prediction = await model.predict(
{
prompt: "an astronaut riding on a horse",
}, {
onUpdate(prediction) {
console.log(prediction.status)
}
}
)
If you'd like to contribute to this package, feel free to open a pull request or open an issue for suggestions. Some features we'd like to add in future include support for file uploads and integration with the paid API.
FAQs
A Node.js client for Replicate.
The npm package node-replicate receives a total of 58 weekly downloads. As such, node-replicate popularity was classified as not popular.
We found that node-replicate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
crates.io adds a Security tab backed by RustSec advisories and narrows trusted publishing paths to reduce common CI publishing risks.

Research
/Security News
A Chrome extension claiming to hide Amazon ads was found secretly hijacking affiliate links, replacing creators’ tags with its own without user consent.

Security News
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.