Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🪙 feat: automatically add start balance (#4486)
MSITE.TOPd9ed1611046f
diff --git a/.env.example b/.env.exampleindex b0a0f20b9f..ac387b8c68 100644--- a/.env.example+++ b/.env.example@@ -352,6 +352,7 @@ ILLEGAL_MODEL_REQ_SCORE=5#========================#CHECK_BALANCE=false+# START_BALANCE=20000 # note: the number of tokens that will be credited after registration.#========================## Registration and Login #diff --git a/api/models/userMethods.js b/api/models/userMethods.jsindex 913ce762e9..63b25edd3a 100644--- a/api/models/userMethods.js+++ b/api/models/userMethods.js@@ -1,5 +1,7 @@const bcrypt = require('bcryptjs');const signPayload = require('~/server/services/signPayload');+const { isEnabled } = require('~/server/utils/handleText');+const Balance = require('./Balance');const User = require('./User');/**@@ -71,6 +73,16 @@ const createUser = async (data, disableTTL = true, returnUser = false) => {}const user = await User.create(userData);++ if (isEnabled(process.env.CHECK_BALANCE) && process.env.START_BALANCE) {+ let incrementValue = parseInt(process.env.START_BALANCE);+ await Balance.findOneAndUpdate(+ { user: user._id },+ { $inc: { tokenCredits: incrementValue } },+ { upsert: true, new: true },+ ).lean();+ }+if (returnUser) {return user.toObject();}