Okay, let's look at a section of the story:
nobody really knows who wrote:20 That night God came to Balaam and said, "Since these men have come to summon you, go with them, but do only what I tell you."
21 Balaam got up in the morning, saddled his donkey and went with the princes of Moab. 22 But God was very angry when he went, and the angel of the LORD stood in the road to oppose him. Balaam was riding on his donkey, and his two servants were with him. 23 When the donkey saw the angel of the LORD standing in the road with a drawn sword in his hand, she turned off the road into a field. Balaam beat her to get her back on the road.
24 Then the angel of the LORD stood in a narrow path between two vineyards, with walls on both sides. 25 When the donkey saw the angel of the LORD, she pressed close to the wall, crushing Balaam's foot against it. So he beat her again.
26 Then the angel of the LORD moved on ahead and stood in a narrow place where there was no room to turn, either to the right or to the left. 27 When the donkey saw the angel of the LORD, she lay down under Balaam, and he was angry and beat her with his staff. 28 Then the LORD opened the donkey's mouth, and she said to Balaam, "What have I done to you to make you beat me these three times?"
29 Balaam answered the donkey, "You have made a fool of me! If I had a sword in my hand, I would kill you right now."
30 The donkey said to Balaam, "Am I not your own donkey, which you have always ridden, to this day? Have I been in the habit of doing this to you?"
"No," he said.
31 Then the LORD opened Balaam's eyes, and he saw the angel of the LORD standing in the road with his sword drawn. So he bowed low and fell facedown.
32 The angel of the LORD asked him, "Why have you beaten your donkey these three times? I have come here to oppose you because your path is a reckless one before me. 33 The donkey saw me and turned away from me these three times. If she had not turned away, I would certainly have killed you by now, but I would have spared her."
34 Balaam said to the angel of the LORD, "I have sinned. I did not realize you were standing in the road to oppose me. Now if you are displeased, I will go back."
35 The angel of the LORD said to Balaam, "Go with the men, but speak only what I tell you." So Balaam went with the princes of Balak.
First God tells Balaam to go with the men. Then God sets up an ambush for Balaam on the road. The donkey sees what is going down and tries to bail three times, but Balaam doesn't have a clue that he's walking into a trap so he beats the donkey to keep her going. Then God causes the donkey to be able to speak so the donkey can ask Balaam what his problem is. Balaam chides the donkey for cramping his style and throws down some threatening tough guy talk for emphasis. The donkey basically calls Balaam an idiot for not knowing how deep in shit he is. Then God reveals Himself to Balaam and says that the donkey has just done him a huge favor because if she hadn't turned away that He would have killed Balaam because he came there specifically to kick Balaam's ass.
Now Balaam is just doing what he was told. God told him to go with the Princes of Balak, so Balaam does it. Then God shows up to "oppose" him because his "path is a reckless one". I suppose you could argue that God disagrees with Balaam's chosen route to Moab, but the story really doesn't give any indication of that. It really does seem that God tells Balaam to go to Moab and then turns around and says "what the f*ck are you going to Moab for?"
Also, God says that if the donkey hadn't turned away that He "would certainly have killed" Balaam. God tells Balaam to go to Moab, then turns up on the road to Moab fully prepared to disembowel him but then just because the donkey is smart enough to not go near a menacing angel brandishing a sword, God all of the sudden decides: "Meh, these aren't the droids we're looking for - move along". WTF?
You know, others have mentioned the apparent disparity between the temperament of God in the Old Testament as opposed to the New Testament. Here we have a disparity between God's temperament in just a few lines of a story. Perhaps God was bipolar and then finally got on some medication just prior to the events of the New testament?