“I give you thanks, O Lord, with my whole heart;
before the gods I sing your praise;” (Psalm 138:1 ESV)
This contradicts Isaiah’s statement (Isaiah 45:5) that there are “no elohim” but the LORD. To get around this the Jewish translators of the Greek Old Testament substituted “gods” with “angels” in this verse – as well as another couple of instances, most famously the mortal self-proclaimed gods in Psalm 82. But the Greek Old Testament makes various substitutions when dealing with difficult to stomach passages in the Hebrew Old Testament. The fact remains that Psalm 138:1 speaks of other gods, which Isaiah 45:5 says do not exist.
The most consistent way to approach Psalm 138:1 is just to take what it says as what it says. There are around 250 instances of elohim in the Old Testament referring to pagan gods. Elohim is one of the small number of Hebrew nouns which are the same in singular and plural. Most of these elohim occur with plural verbs, “gods”, but in a few cases a single pagan elohim can also occur with a singular verb, “great god”, though normally elohim with singular verb is 2,340 times reserved for the One God, the LORD.
Psalm 138:1 then is not more proof of the existence of other gods than any of the places in the Old Testament where human attributes or activities are applied to non-existent gods.
All worshipers of images are put to shame, who make their boast in worthless idols; worship him, all you gods! (Psalm 97:7)
These gods cannot literally worship the One God, because they only exist in men’s minds and as idols of wood and stone “with no spirit in them”.
Every man is stupid and without knowledge; every goldsmith is put to shame by his idols, for his images are false, and there is no breath in them. (Jeremiah 10:14, repeated 51:17)
These terms for idols (Hebrew pesel) and images (Hebrew nesek) are used instead of elohim in many verses in the Old Testament. But we also have idols and also named gods showing human actions as if they exist, in the same context as the prophets make it clear that they do not exist:
An oracle concerning Egypt. Behold, the Lord is riding on a swift cloud and comes to Egypt; and the idols of Egypt will tremble at his presence, and the heart of the Egyptians will melt within them. (Isaiah 19:1)
Bel bows down; Nebo stoops; their idols are on beasts and livestock; these things you carry are borne as burdens on weary beasts. (Isaiah 46:1 )
The idols of Egypt tremble, but do not exist. Bel and Nebo are among the elohim of Babylon, they bow and stoop, but again do not really exist.