Image Generation
The image generations endpoint allows you to create an original image given a text prompt.
By default, images are generated at standard
quality, but when using DALLĀ·E 3 you can set quality: "hd"
for enhanced detail. Square, standard quality images are the fastest to generate.
There are at least 40 different kind of image generation models available as of now, each suited for different tasks but in general are decent for usage.
The endpoint for image generation is not behind an SSL as of now, so you can use it directly through the HTTP domain: http://api.webraft.in:1234/api/images/generations .
Usage with Python
Using image generation with python is fairly easy, we are going to use the well-known requests library for requesting the webraft api and handling the response.
Before starting, make sure you have installed the requests library.
You can install it through the command pip install requests
After that, you can use the following code:
The response will include a url of the image which is saved on the webraftai server.
Usage with Curl
In this example, we are going to use the curl software for handling the request to the api. In linux this is pre-installed, but if you are using any other os then install it before using the below code.
The response here will also include a url of the image, which is saved on the webraftai server.
Usage with Node.js
First make sure that you have axios
installed on your node.js environment. You can do so by running the command mentioned below:
Then, you can use the following code:
Response
If the API gave a 200 response status code then a json structure would have also been received. The sample response structure for the given default values is -
Sample response:
Note: Only 1 image is returned per request, the url contains a png/jpg file stored on a public webserver owned by Webraft Cloud.
Conclusion
There are various methods available to access image generation models, we have only listed the usage of our api in 3 major known libraries. Users are free to use webraftai api in different programming languages and/or different applications of their choice.
Next up, we are going to talk about usage of the Embeddings Endpoint.
Last updated