
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Use the Stability.ai API with Ruby! 🤖❤️
Generate images with Stability AI, get engines, accounts and balance
Add this line to your application's Gemfile:
gem "ruby-stabilityai"
And then execute:
$ bundle install
Or install with:
$ gem install ruby-stabilityai
and require with:
require "stabilityai"
For a quick test you can pass your token directly to a new client:
client = StabilityAI::Client.new(access_token: "access_token_goes_here")
For a more robust setup, you can configure the gem with your API keys, for example in an stabilityai.rb
initializer file. Never hardcode secrets into your codebase - instead use something like dotenv to pass the keys safely into your environments.
StabilityAI.configure do |config|
config.access_token = ENV.fetch('STABILITYAI_ACCESS_TOKEN')
config.organization_id = ENV.fetch('STABILITYAI_ORGANIZATION_ID') # Optional.
end
Then you can create a client like this:
client = StabilityAI::Client.new
The default timeout for any Stability.ai request is 120 seconds. You can change that passing the request_timeout
when initializing the client.
client = StabilityAI::Client.new(
access_token: "access_token_goes_here",
request_timeout: 240,
engine_id: "/stable-diffusion-v1-5"
)
or when configuring the gem:
StabilityAI.configure do |config|
config.access_token = ENV.fetch("STABILITYAI_ACCESS_TOKEN")
config.organization_id = ENV.fetch("STABILITYAI_ORGANIZATION_ID") # Optional
config.engine_id = "/stable-diffusion-v1-5"
config.request_timeout = 240 # Optional
end
There are different engines that can be used to generate images. For a full list:
client.engines
Get an overview of accounts connected to your user:
response = client.account
puts response
# => "{"email":"email@email.com","id":"user-abcdefghijklmn","organizations":[{"id":"org-abcdefghijklmn","is_default":true,"name":"Personal","role":"OWNER"}],"profile_picture":"https://lh3.googleusercontent.com/a/abcdefghijklmn"}"
Get feedback, how much balance is left in your account:
response = client.balance
puts response
# => {"credits":1001.73012}
Send a string and additional settings to create your image:
response = client.text_to_image(
parameters: {
text_prompts: [
{
text: "A red candle"
}
],
cfg_scale: 7,
clip_guidance_preset: "FAST_BLUE",
height: 512,
width: 512,
samples: 1,
steps: 30
}
)
data = response.dig("artifacts", 0, "base64")
# => Outputs base64 string, which can be used in an image tag like this <img src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAACEmVYSWZNTQAq..."">
More information can be found here: Stability AI Text to Image
FAQs
Unknown package
We found that ruby-stabilityai 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.