{"record":{"id":"e5d7709fadf20ce4","repo":"danny-avila/LibreChat","slug":"req-baseurl-endpoint-is-required","errorCode":null,"errorMessage":"[${req.baseUrl}] Endpoint is required","messagePattern":"\\[(.+?)\\] Endpoint is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/server/controllers/assistants/helpers.js","lineNumber":192,"sourceCode":"    data,\n  };\n};\n\n/**\n * Initializes the OpenAI client.\n * @param {object} params - The parameters object.\n * @param {ServerRequest} params.req - The request object.\n * @param {ServerResponse} params.res - The response object.\n * @param {TEndpointOption} params.endpointOption - The endpoint options.\n * @param {boolean} params.initAppClient - Whether to initialize the app client.\n * @param {string} params.overrideEndpoint - The endpoint to override.\n * @returns {Promise<{ openai: OpenAI, openAIApiKey: string }>} - The initialized OpenAI SDK client.\n */\nasync function getOpenAIClient({ req, res, endpointOption, initAppClient, overrideEndpoint }) {\n  let endpoint = overrideEndpoint ?? req.body?.endpoint ?? req.query?.endpoint;\n  const version = await getCurrentVersion(req, endpoint);\n  if (!endpoint) {\n    throw new Error(`[${req.baseUrl}] Endpoint is required`);\n  }\n\n  let result;\n  if (endpoint === EModelEndpoint.assistants) {\n    result = await initializeClient({ req, res, version, endpointOption, initAppClient });\n  } else if (endpoint === EModelEndpoint.azureAssistants) {\n    result = await initAzureClient({ req, res, version, endpointOption, initAppClient });\n  }\n\n  return result;\n}\n\n/**\n * Returns a list of assistants.\n * @param {object} params\n * @param {object} params.req - Express Request\n * @param {AssistantListParams} [params.req.query] - The assistant list parameters for pagination and sorting.\n * @param {object} params.res - Express Response","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/controllers/assistants/helpers.js#L174-L210","documentation":"Thrown by getOpenAIClient after it resolves the API version but finds no endpoint identifier. The endpoint is sourced from overrideEndpoint, then req.body.endpoint, then req.query.endpoint; if all are absent the call cannot decide whether to initialize the OpenAI or Azure Assistants client and aborts.","triggerScenarios":"A POST/GET to the assistants controller that omits the 'endpoint' field in both body and query, and is invoked without an explicit overrideEndpoint argument (e.g. a direct programmatic call or a client that previously relied on a default).","commonSituations":"Frontend form that stopped sending the endpoint field after a refactor; a custom integration calling the assistants API directly without setting endpoint to 'assistants' or 'azureAssistants'; a misrouted request hitting this controller for a non-assistants action.","solutions":["Include endpoint: 'assistants' (or 'azureAssistants') in the request body or query string.","If calling getOpenAIClient server-side, pass overrideEndpoint explicitly.","Verify the client/integration still sends the endpoint field after upgrades to the assistants API."],"exampleFix":"// before\nfetch('/api/assistants', { method: 'POST', body: JSON.stringify({ name }) })\n// after\nfetch('/api/assistants', { method: 'POST', body: JSON.stringify({ name, endpoint: 'assistants' }) })","handlingStrategy":"validation","validationCode":"const endpoint = overrideEndpoint ?? req.body?.endpoint ?? req.query?.endpoint;\nif (!endpoint) {\n  return res.status(400).json({ error: 'endpoint query/body parameter is required' });\n}","typeGuard":"function hasEndpointArg(req, override) {\n  const e = override ?? req.body?.endpoint ?? req.query?.endpoint;\n  return typeof e === 'string' && e.length > 0;\n}","tryCatchPattern":"try { await getOpenAIClient({ req, res }); }\ncatch (e) { if (/Endpoint is required/.test(e.message)) return res.status(400).json({ error: e.message }); throw e; }","preventionTips":["Make the endpoint field required in the request schema/DTO.","Default to 'assistants' on the client when the user selects that provider.","Fail fast in middleware if endpoint is missing for assistants routes."],"tags":["assistants","validation","request-validation"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}