Image by Ulysses0302. Please do not use without permission
Galen met the original K9 while he was locked in his quarters on Gallifrey, awaiting trial. The Doctor knew that Galen would need help escaping, and, unable to provide it directly, had sent K9 to offer covert assistance. Galen was charmed and impressed by the robot's personality and capabilities, although the robotics specialist in him saw considerable scope for improvements.
He asked K9 for a copy of his specifications and programming, and, in the extensive free time offered by his incarceration, started designing upgrades. The Doctor's Presidential security codes, supplied by K9, allowed access to most of the Capitol's restricted systems - including the automated manufacturing facilities. Using them, Galen was able to build his own K9 unit by remote control and infiltrate him into the TARDIS assigned to carry him into exile. Since the original K9 had been created by an Earth scientist, Galen decided to name his creation after an Earth legend - the Gwyllgi, a spectral hound that waylays unwary travelers. It struck him as ironically appropriate, given that Gwyllgi's first job would be to waylay the (hopefully) unwary guards assigned to carry out Galen's sentence
Gwyllgi mostly has the traits of a standard K9 model, but he moves around on antigravs rather than treaded tracks, giving him a fair turn of speed and no problems with stairs or rough terrain. He's also equipped with a holographic Shimmer that allows him to assume the appearance of his mythological namesake, an immense, spectral black hound with glowing red eyes.