Generating a 3D grid
I came up with two scripts, one which "brutally" instantiates verts and edges, then converts it to a curve in order to add thickness.

import bpy


mesh = bpy.data.meshes.new('Mesh_Grid')
obj = bpy.data.objects.new('Obj_Grid', mesh)

rows, columns, levels = 10, 10, 10
wire_thickness = 0.02

verts, edges = [], []

i = 0
for l in range(levels):
    for r in range(rows):
        for c in range(columns):
            verts.append((c, r, l))
            if c &lt; columns - 1:
                edges.append((i, i + 1))
            if r &lt; rows - 1:
                edges.append((i, i + columns))
            if l &lt; levels - 1:
                edges.append((i, i + (rows * columns)))
            i += 1

mesh.from_pydata(verts, edges , [])

bpy.context.scene.collection.objects.link(obj)

obj.select_set(True)
bpy.context.view_layer.objects.active = obj

bpy.ops.object.convert(target='CURVE')

obj.data.bevel_depth = wire_thickness


Result : 

And the other one which is the same as @Vega_KH's answer, but as a script. I just added a weld modifier in order to avoid duplicate geometry. (Need Blender 2.82+) :

import bpy

dimensions = (10,10,10)
wf_thickness = 0.1

bpy.ops.mesh.primitive_cube_add(enter_editmode=False, location=(0, 0, 0))
cube = bpy.context.selected_objects[0]

for i in range(3):
    mod = cube.modifiers.new('Array_' + str(i), 'ARRAY')
    mod.relative_offset_displace[0] = 0
    mod.relative_offset_displace[i] = 1
    mod.count = dimensions[i]

cube.modifiers.new('WD', 'WELD')
wf = cube.modifiers.new('WF', 'WIREFRAME') 
wf.thickness = wf_thickness


Result :