Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
stability-rest
Advanced tools
This is a rest client to interface with Stability.ai's API. As this requires an API key, server-side usage is recommended.
⚠️ This is a work in progress. Stability.ai Rest API is still in beta and is subject to change.
$ npm install stability-rest
import {
ClipGuidancePreset,
GenerationSampler,
StabilityClient,
WellKnownEngine,
} from "stability-rest";
import * as fs from "fs";
const client = new StabilityClient(process.env.STABILITY_API_KEY);
client.generation
.textToImagePng(
WellKnownEngine["stable-diffusion-512-v2-1"],
"a pale blue planet in the depth of the space",
{
width: 512,
height: 512,
cfg_scale: 7.0,
sampler: GenerationSampler.K_EULER_ANCESTRAL,
clip_guidance_preset: ClipGuidancePreset.FAST_BLUE,
steps: 20,
samples: 1,
seed: 10,
}
)
.then((response) => {
fs.writeFileSync("out.png", response.data);
});
const {
StabilityClient,
WellKnownEngine,
GenerationSampler,
ClipGuidancePreset,
} = require("stability-rest");
const fs = require("fs");
const client = new StabilityClient(process.env.STABILITY_API_KEY);
client.generation
.textToImagePng(
WellKnownEngine["stable-diffusion-512-v2-1"],
"a pale blue planet in the depth of the space",
{
width: 512,
height: 512,
seed: 123,
cfg_scale: 7.0,
sampler: GenerationSampler.K_EULER_ANCESTRAL,
clip_guidance_preset: ClipGuidancePreset.FAST_BLUE,
steps: 20,
samples: 1,
}
)
.then((response) => {
fs.writeFileSync("out.png", response.data);
});
This client maps 1-1 with the Stability API. For more information, please refer to the API documentation.
const client = new StabilityClient(process.env.STABILITY_API_KEY);
// UserResource
client.user.account(); // GET /user/account
client.user.balance(); // GET /user/balance
// EngineResource
client.engine.list(); // GET /engines/list
// GenerationResource
client.generation.textToImage(engineId, prompt, options); // POST /generation/:engineId/text-to-image
client.generation.textToImagePng(engineId, prompt, options); // POST /generation/:engineId/text-to-image - this one returns an arraybuffer.
getArtifactBuffer(artifact)
Convert an artifact base64 string to a buffer.
WellKnownEngine
A list of well-known engines. This might be outdated as it is
statically defined. You can also call StablityClient.engine.list()
to get a list of all engines.
Contributions are welcome! Please open an issue or PR. There are no guidelines yet, but please follow the existing code style.
List of things that need to be done:
.env
file with your API key. Set the key as STABILITY_API_KEY
.$ npm run test
Then create a PR once all the tests pass.
We do not mock the API calls in the tests. This is to ensure that the client is working as expected. However, this means that you need to have a valid API key to run the tests.
⚠️ Please do not use your production API key to run the tests. You can create a new API key in DreamStudio. Running the tests might consume your API quota.
MIT © Aditya Purwa
FAQs
Client for Stability.ai REST API
We found that stability-rest 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.