@axiom-lattice/react-sdk 2.1.68 → 2.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -307,16 +307,22 @@ function AxiomLatticeProvider({
307
307
  }) {
308
308
  const authContext = useContext2(AuthContext);
309
309
  const tenantId = authContext?.currentTenant?.id;
310
+ const effectiveApiKey = useMemo(() => {
311
+ if (authContext?.isAuthenticated) {
312
+ return sessionStorage.getItem("lattice_token") || config.apiKey;
313
+ }
314
+ return config.apiKey;
315
+ }, [authContext?.isAuthenticated, authContext?.currentTenant?.id, config.apiKey]);
310
316
  const clientCacheRef = useRef(/* @__PURE__ */ new Map());
311
317
  const baseConfig = useMemo(
312
318
  () => ({
313
319
  baseURL: config.baseURL,
314
- apiKey: config.apiKey,
320
+ apiKey: effectiveApiKey,
315
321
  assistantId: "__BASE__",
316
322
  // 占位符,不会被直接使用
317
323
  transport: config.transport
318
324
  }),
319
- [config.baseURL, config.apiKey, config.transport]
325
+ [config.baseURL, effectiveApiKey, config.transport]
320
326
  );
321
327
  const baseClient = useMemo(() => {
322
328
  const client = new Client(baseConfig);