Skip to content

A easy to use codebase for hosting a free openai server on firebase and interacting with it using javascript fetch

License

Notifications You must be signed in to change notification settings

solomoncools/firebase-openai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

firebase-openai

A easy to use codebase for hosting a openai server on firebase and interacting with it using javascript fetch. This solution is better and cheaper than using heroku. Includes functions for text prompts and image generation

Requirements

  1. Node.js
  2. npm
  3. Firebase account
  4. OpenAI API key
  5. A couple bucks

Instructions

  1. First create a new firebase project using your chosen command line interface:
  • npm install -g firebase-tools

  • firebase init

  • enable functions and hosting

  1. Install OpenAI
  • cd functions

  • npm install openai

  1. Copy contents of functions/index.js from this repo into your functions/index.js file

  2. In index.js modify chunk1,2,3,4 and 5 variables to include snippets of your openai apikey.

  • You must segment the key because the maximum length of a line allowed in firebase functions is 80 chars at the time of writing this.
  1. Deploy firebase functions
  • firebase deploy --only functions

  • Upgrade your project to Blaze (pay-as-you-go) it is very cheap. Like around $1. You pay at the end of the month

  • Deploy again

  • firebase deploy --only functions

    • COPY THE FUNCTION URL DISPLAYED BY THE CLI
  1. Modify your index.html to include jquery and the javascript code from the repo index.html

  2. Modify functionUrl variable in index.html to be the function url you copied in step 5

  3. Move your index.html into your /public hosting deploy folder

  4. Deploy html

  • firebase deploy --only hosting

About

A easy to use codebase for hosting a free openai server on firebase and interacting with it using javascript fetch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published