Skip to content

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

1009 B
Raw Blame
import { useMemo } from 'react';
import { Permissions, PermissionTypes } from 'librechat-data-provider';
import { useGetEndpointsQuery, useGetStartupConfig } from '~/data-provider';
import { getUserKeyEndpoints } from './utils';
import { useHasAccess } from '~/hooks';

/**
 * Reachable endpoints requiring a user-provided key, filtered the same way the model
 * selector and mention popover are (modelSpecs, addedEndpoints, agent allowedProviders).
 */
export default function useProviderKeys(): string[] {
  const { data: endpointsConfig } = useGetEndpointsQuery();
  const { data: startupConfig } = useGetStartupConfig();
  const hasAgentAccess = useHasAccess({
    permissionType: PermissionTypes.AGENTS,
    permission: Permissions.USE,
  });

  return useMemo(
    () =>
      getUserKeyEndpoints({
        endpointsConfig,
        modelSpecs: startupConfig?.modelSpecs,
        hasAgentAccess: hasAgentAccess === true,
      }),
    [endpointsConfig, startupConfig?.modelSpecs, hasAgentAccess],
  );
}