This repository contains an Express.js server that provides an API for generating images from text prompts using the Stability AI platform. Below, we'll explain the process, technologies used, and the available endpoints along with instructions on how to use them.
- Express.js: A web application framework for Node.js used to build the API endpoints.
- node-fetch: A library used to make HTTP requests from the Node.js environment.
- fs: A built-in Node.js module used to interact with the file system.
This endpoint generates an image based on the provided text prompt.
- prompt: (Optional) The text prompt used to generate the image. If not provided, a default prompt will be used.
-
Make a GET request to
/generate-image
with theprompt
query parameter to generate an image. For example: https://stability-ai-api.onrender.com/generate-image?prompt={optional} -
The generated image will be returned as a response in JSON format with an array of image URLs.
This endpoint provides a welcome message indicating the server is running.
- Make a GET request to
/
to receive the welcome message.
Static files (images) are served from the current directory.
- Clone the repository.
- Install dependencies using
npm install
. - Set your Stability API key and host in the environment variables (
STABILITY_API_KEY
andAPI_HOST
respectively). - Start the server using
npm start
.
Let's say you want to generate an image of "a lady walking on beach, close up":
- Make a GET request to
https://stability-ai-api.onrender.com/generate-image?prompt=a%20lady%20walking%20on%20beach,%20close%20up
. - The server will generate the image and return an array of URLs where the images are stored.
- You can access the generated image by visiting the provided URL in your browser.
That's it! You've successfully used the Image Generation API provided by this repository.🎉🎉