MCPcopy Create free account
hub / github.com/21st-dev/21st-sdk / buildOpenRouterRequestBody

Function buildOpenRouterRequestBody

apps/proxy/src/server.js:433–450  ·  view source on GitHub ↗
(body, req)

Source from the content-addressed store, hash-verified

431}
432
433function buildOpenRouterRequestBody(body, req) {
434 const sessionId = req.proxyAuth?.clientSandboxId || req.proxyAuth?.sandboxId
435 const trace = isObject(body?.trace) ? body.trace : {}
436
437 return {
438 ...body,
439 ...(body?.user ? {} : req.proxyAuth?.teamId ? { user: req.proxyAuth.teamId } : {}),
440 ...(body?.session_id ? {} : sessionId ? { session_id: sessionId } : {}),
441 trace: {
442 ...trace,
443 billing_request_id: randomUUID(),
444 ...(req.proxyAuth?.teamId ? { team_id: req.proxyAuth.teamId } : {}),
445 ...(req.userId ? { user_id: req.userId } : {}),
446 ...(req.proxyAuth?.sandboxId ? { sandbox_id: req.proxyAuth.sandboxId } : {}),
447 ...(req.proxyAuth?.clientSandboxId ? { client_sandbox_id: req.proxyAuth.clientSandboxId } : {}),
448 },
449 }
450}
451
452app.use('/', createProxyMiddleware({
453 router: (req) => {

Callers 1

server.jsFile · 0.85

Calls 1

isObjectFunction · 0.85

Tested by

no test coverage detected