For best results use the line output(s), unless the keyboard has built-in balanced outputs (some high end units only) which are essentially built-in DI units and should give the best results of all.
If monitor amplifiers are also to be driven directly from the keyboard, the DI unit must have a passthrough connector. Alternatively, take a signal from the amplifier instead, see below.
Passive balun type
A DI can be used to take a line in from an electric guitar. When dealing with electric guitars and electric guitar amplifiers, better results will often (not always) be obtained by instead using a microphone in front of the loudspeaker. This is because the tone of the guitar is often shaped by the amplifier and speaker used in the setup.
A DI in the chain before the speaker or amplifier will often result in a loss of fullness or pleasant tone. Using a microphone eliminates hum from ground loops which are often troublesome when using DI units with mains-powered amplifiers. But a microphone will of course pick up background noise which a DI connection will not, and will most often be more susceptible to feedback in live situations.
If an electric guitar is to be connected to a DI and an amplifier is to be connected as well, then the DI unit must have a passthrough connector. Alternatively take a signal from the amplifier, see below. For players using effects (including distortion) built in to their amplifiers, this is the only option, otherwise the contribution of these effects will be lost.
If a passthrough is used, normally the DI unit is between any effects units and the amplifier for the same reason.
Passive balun type
Electric bass guitar/Acoustic guitar
When dealing with electric bass or acoustic guitar, a DI is most often preferrable to using a microphone on an amplifier. This is because these instruments are often valued in a mix for being clean.
The signal path from the instrument should go into the DI unit and should then pass through to any sort of instrument amplifier. Often any amp used in this setup would be for monitoring purposes only, with the major component of the sound coming from the balanced send of the DI. The DI should be chosen with the specifications of the individual instrument in mind.
Often the best possible tone is achieved by one stage of preamplification. Following this idea, an active instrument, which means that the instrument has a preamplifier inside of it, should utilize a passive DI unit, while a passive instrument, meaning there is no preamplifier inside, should utilize an active DI.