Skip to content

Latest commit

 

History

History
125 lines (79 loc) · 4.91 KB

README.md

File metadata and controls

125 lines (79 loc) · 4.91 KB

Bridge2AI 🚧🚧

This API is a solution for developers who want to use OpenAI's text and image generation technology in their applications. With multiple endpoints available, it is possible to generate text, images, and edit images using specific prompts and models.

How to use

To use this API, it is necessary to send an HTTP request to one of the available endpoints, providing the necessary inputs for text or image generation. It is important to note that the API performs validations to ensure that the inputs are valid before sending requests to OpenAI to ensure accurate and relevant responses.

Please include that to use the API, the user needs to add the API key generated on the OpenAI website, and the billing is based on usage, but it is very affordable compared to the rate set by the "plus" of ChatGPT.

Clone the project

  git clone https://github.com/matheuskroska/Bridge2AI.git

Go to the project directory

  cd my-project

Install dependencies

  npm install || yarn

Set Environment variables

To run this project, you will need to add the following environment variables to your .env file

OPENAI_API_KEY USER PASSWORD SECRET_KEY

Start

  node app

API Documentation

  POST /completion

Returns a text generated by the OpenAI API based on the provided prompt.

Request Body

Parameter Type Description
prompt string A string representing the prompt to generate text completion for.

Query Parameters

Parameter Type Description
max_tokens integer The maximum number of tokens to generate. Defaults to 50.
temperature float A number from 0 to 1 that determines the 'creativity level' of the generated text. The closer to 0, the more conservative the text will be. The closer to 1, the more creative and unpredictable the text will be. Default: 0.
  POST /image

Returns an image based on prompt

Request Body

Parameter Type Description
prompt string A string representing the prompt to generate image

Query Parameters

Parameter Type Description
n integer Number of generated outputs. Defaults to 1.
size string The size of the output image. It must be in the format "width x height". Defaults to "256x256".
  POST /image-edit

The user uploads an input image file and a binary mask file that defines which areas of the input image should be edited. The API will then generate an edited output image file based on the input image and mask.

Request Body

Parameter Type Description
inputImage file The input image to be edited.
mask file A binary image that defines the area of the input image to be edited. Where pixel value 0 represents pixels that should not be edited and pixel value 1 represents pixels that should be edited.
prompt string Optional string that can be used to provide additional instructions for the image editing.
n integer Number of generated outputs. Defaults to 1.
size string The size of the output image. It must be in the format "width x height". Defaults to "256x256".
  POST /authenticate

This endpoint is used to authenticate users by checking their provided username and password against stored credentials. The endpoint expects a POST request with a JSON payload containing the username and password.

If the username and password match the stored credentials, the server generates a JSON Web Token (JWT) for the user and returns it in the response.

This endpoint allows users to log in to the application by verifying their identity with a username and password.

Request Body

Parameter Type Description
username string user credential
password string password credential

Conclusion

Bridge2AI is a powerful and secure tool for interacting with OpenAI's generation API. With text, image, and image editing endpoints available, it is possible to explore the possibilities offered by OpenAI and create innovative and impressive applications.