Can't texture a plane created using BMesh API I'm really new to blender (2.9) and I'm exploring its Python API. I'm also comparing the API with the normal GUI tools. At the moment I'm trying  to create a textured plane without the use of the function:
bpy.ops.mesh.primitive_plane_add()

The main reason is for experimenting purposes. For this reason I'm trying to use BMesh and so far i got this:
import bmesh
# Construct the bmesh cube and assign it to the blender mesh.
bm = bmesh.new()
bmesh.ops.create_grid(bm, x_segments = 1, y_segments = 1, size = 1.0)
#bmesh.ops.create_cube(bm, size = 1.0)

# Finish up, write the bmesh into a new mesh
me = bpy.data.meshes.new(&quot;Chessboard_Plan&quot;)
bm.to_mesh(me)
bm.free()

# Add the mesh to the scene
obj = bpy.data.objects.new(&quot;Chessboard_Plan&quot;, me)
bpy.context.collection.objects.link(obj)

# Select and make active
bpy.context.view_layer.objects.active = obj
obj.select_set(True)

The Plane is shown correctly:

I can give it a base color:

but I when i try to apply an image texture i only get this weird blue shade:

it should appear like this:

Is there something wrong with the way I create the plane and put it in the scene?
Add a UV layer.
Speculating that the issue here is having no UV map when assigning image texture. The blue colour seen in question is likely pixel (0, 0) of your image, since without a UV layer will use default UV value of (0, 0) for all
By default most faced add primitive operators create UV's by default
bpy.ops.mesh.primitive_plane_add(calc_uvs=True)

if creating with bmesh as in question code will need to create the UV map, either as below by adding as a bmesh loop uv layer
import bmesh
import bpy
from bpy import context

me = bpy.data.meshes.new(&quot;Foo&quot;)
bm = bmesh.new()
bm.loops.layers.uv.new(&quot;Foo&quot;)
bmesh.ops.create_grid(
    bm,
    size=1,
    x_segments=1,
    y_segments=1,
    calc_uvs=True,
    )
bm.to_mesh(me)

context.collection.objects.link(
    bpy.data.objects.new(&quot;Foo&quot;, me)
    )

or by adding a UV to the mesh when created
&gt;&gt;&gt; C.object.data.uv_layers.new(name=&quot;Foo&quot;)
bpy.data.meshes['Foo'].uv_layers[&quot;Foo&quot;]