[verb (plain)] + と思いきや [i-adj] + と思いきや [na-adj] + だ + と思いきや [noun] + だ + と思いきや
と思いきや follows a plain-form clause stating what you expected, and the second half says what actually happened instead: "I thought…, but", "just when I thought…". A noun or な-adjective takes だ before it.
The surprise can go either way, good or bad. The second half is something that happened, usually in the past, so it is never a request or your own plan.
と思いきや is written, and in speech it sounds deliberately dramatic or jokey. In ordinary conversation, say とおもった思ったけど or とおもったら思ったら.