{"id":22191925,"url":"https://github.com/klich3/firebase-gpt-chat-completion","last_synced_at":"2026-05-04T02:38:59.450Z","repository":{"id":182020242,"uuid":"645304186","full_name":"klich3/firebase-gpt-chat-completion","owner":"klich3","description":"Function for use of GPT Api for chat completion in Firebase ","archived":false,"fork":false,"pushed_at":"2023-07-18T11:26:45.000Z","size":21,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T01:17:17.226Z","etag":null,"topics":["firestore","firestore-function","nodejs16","react","reactfire"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klich3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null},"funding":{"ko_fi":"klich3"}},"created_at":"2023-05-25T11:07:37.000Z","updated_at":"2024-10-22T22:34:28.000Z","dependencies_parsed_at":"2023-07-18T13:32:07.127Z","dependency_job_id":null,"html_url":"https://github.com/klich3/firebase-gpt-chat-completion","commit_stats":null,"previous_names":["klich3/firebase-gpt-chat-completion"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Ffirebase-gpt-chat-completion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Ffirebase-gpt-chat-completion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Ffirebase-gpt-chat-completion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klich3%2Ffirebase-gpt-chat-completion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klich3","download_url":"https://codeload.github.com/klich3/firebase-gpt-chat-completion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245351762,"owners_count":20601090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["firestore","firestore-function","nodejs16","react","reactfire"],"created_at":"2024-12-02T12:18:25.308Z","updated_at":"2026-05-04T02:38:54.399Z","avatar_url":"https://github.com/klich3.png","language":"JavaScript","funding_links":["https://ko-fi.com/klich3"],"categories":[],"sub_categories":[],"readme":"# Firebase Cloud Functions for GPT Chat Completion\n\n![firebase+gpt](images/firebase_and_gpt.jpg?raw=true)\n\nExample of ChatGPT implementation in Firebase with functions. They are via internal calls with call and response.\n***Issue:***: This method seems to be slower than the other Stream method because it does not stream.\n\n## SETUP\n\nIn `functions` folder create file `.env` with your OpenAI Api key.\n\nSample: \n```text\nOPEN_AI_KEY=\"sk-\u003cyour key here\u003e\"\n```\n\n## SETUP WITH CUSTOM FUNCTIONS FOLDER\n\nTo use functions in a custom folder different from the default, suppose the destination folder is `functions` inside we create a new folder named `gpt-chat-completion` and copy files from this project that are inside the `functions` folder. Then edit the `firebase.json` file from the root folder of your project.\n\n```json\n{\n\t...\n\t\"firestore\": {\n\t\t...\n\t},\n\t...\n\t\"functions\": [\n\t\t{\n\t\t\t\"source\": \"functions/gpt-chat-completion\",\n\t\t\t\"codebase\": \"gpt-chat-completion\",\n\t\t\t\"predeploy\": [\"npm --prefix \\\"$RESOURCE_DIR\\\" run lint\"],\n\t\t\t\"ignore\": [\n\t\t\t\t\"node_modules\",\n\t\t\t\t\".git\",\n\t\t\t\t\"firebase-debug.log\",\n\t\t\t\t\"firebase-debug.*.log\"\n\t\t\t],\n\t\t\t\"runtime\": \"nodejs16\"\n\t\t}\n\t]\n\t...\n}\n```\n\n## Deploy\n\nRun `firebase deploy --only functions:gpt-chat-completion`\n\n## Sample usage in REACT\n\n```javascript\n\nimport { httpsCallable } from \"firebase/functions\";\nimport {\n\tuseFunctions,\n} from \"reactfire\";\n...\n\nconst functions = useFunctions();\nconst gptPrompt = httpsCallable(functions, \"gptPrompt\");\n\ngptPrompt({prompt: [{role: \"user\", content: \"Hello world\"}]})\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklich3%2Ffirebase-gpt-chat-completion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklich3%2Ffirebase-gpt-chat-completion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklich3%2Ffirebase-gpt-chat-completion/lists"}