Control the speed of a fan

I have loaded openhab2 in my RPI , I have connected a fan to my relay and relay is connected to RPI GPIO pin.I want to control the speed of a fan , What is the code i must enter in the items file.Please do help me out.

A relay turns things on and off.
Tell us more about the fan - is it mains power? Does it have a knob or pushbuttons for speed control?

yes fan is connected to main power! Do i need any other hardware to control speed? can’t I do it through GPIO pin?

Okay, we seem to have a mains fan with no speed controls. No, you won’t be able to control speed with an on/off GPIO pin and relay.

There are hundreds of fan speed controller boxes, but not many allow control from some external system like Openhab.
Try googling home automation fan speed controller for some ideas

okay!