diff --git a/TemporaryTest/store.ts b/TemporaryTest/store.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/packages/rtk-query-codegen-openapi/src/generate.ts b/packages/rtk-query-codegen-openapi/src/generate.ts
index d128d100b4..0b147b9a9d 100644
--- a/packages/rtk-query-codegen-openapi/src/generate.ts
+++ b/packages/rtk-query-codegen-openapi/src/generate.ts
@@ -117,6 +117,7 @@ export async function generateApi(
     useEnumType = false,
     mergeReadWriteOnly = false,
     httpResolverOptions,
+    ESMExtensions = false
   }: GenerationOptions
 ) {
   const v3Doc = (v3DocCache[spec] ??= await getV3Doc(spec, httpResolverOptions));
@@ -161,7 +162,19 @@ export async function generateApi(
       if (!apiFile.startsWith('.')) apiFile = `./${apiFile}`;
     }
   }
-  apiFile = apiFile.replace(/\.[jt]sx?$/, '');
+  
+  if(ESMExtensions === true){
+  apiFile = apiFile.replace(/\.js$|\.ts$|\.mjs$|\.mts$|\.jsx$|\.tsx$/, (extension) => {
+    if (extension ==='.js') return '.js';
+    if (extension ==='.ts') return '.js';
+    if (extension ==='.mjs') return '.mjs';
+    if (extension ==='.mts') return '.mjs';
+    if (extension ==='.jsx') return '.jsx';
+    if (extension ==='.tsx') return '.jsx';
+    return apiFile;
+  });
+};
+if(!ESMExtensions || ESMExtensions === false){apiFile = apiFile.replace(/\.[jt]sx?$/, '');};
 
   return printer.printNode(
     ts.EmitHint.Unspecified,
diff --git a/packages/rtk-query-codegen-openapi/src/types.ts b/packages/rtk-query-codegen-openapi/src/types.ts
index 437e058087..c49383edda 100644
--- a/packages/rtk-query-codegen-openapi/src/types.ts
+++ b/packages/rtk-query-codegen-openapi/src/types.ts
@@ -111,6 +111,11 @@ export interface CommonOptions {
    * resolution mechanism will be used.
    */
   prettierConfigFile?: string;
+  /**
+   * default to false
+   * Will generate imports with file extension matching the expected compiled output of the api file
+   */
+  ESMExtensions?:boolean;
 }
 
 export type TextMatcher = string | RegExp | (string | RegExp)[];