How to add Inputs and Outputs to Group Node using Python

Hi GoldenDragon,

in Blender 4.0 the inputs and outputs got removed from the NodeTree
Now you have to add them to the NodeTree interface. Here’s a modified version of your function:

Code
def create_custom_node_group():
    
    # Create new node group
    group = bpy.data.node_groups.new('custom group', 'ShaderNodeTree')
    
    # Define interface
    color_input = group.interface.new_socket(
        name="Color",
        description="Color input",
        in_out='INPUT',
        socket_type='NodeSocketColor'
    )
    color_input.default_value = (1.0, 1.0, 1.0, 1.0)
    
    color_output = group.interface.new_socket(
        name="Color",
        description="Color output",
        in_out='OUTPUT',
        socket_type='NodeSocketColor'
    )
    color_output.default_value = (0.0, 0.0, 0.0, 1.0)
    
    # Create nodes
    nodes = group.nodes
    group_in = nodes.new(type='NodeGroupInput')
    group_in.location = (-200, 0)

    group_out = nodes.new(type='NodeGroupOutput')
    group_out.location = (200, 0)
    
    mix_node = nodes.new(type='ShaderNodeMix')
    mix_node.location = (0, 0)
    mix_node.data_type = 'RGBA'
    mix_node.inputs[0].default_value = 0.6
    mix_node.inputs[7].default_value = (0.0, 1.0, 0.0, 1.0)

    # Create links
    links = group.links
    links.new(group_in.outputs[0], mix_node.inputs[6])
    links.new(mix_node.outputs[2], group_out.inputs[0])

    return group