On further experimentation, I prompted Opus 4.6 to make me a frontend artifact that used the Anthropic API, and I confirmed that it worked as expected.
Here is the only relevant part of the prompt it used when calling the API endpoint:
> - Track the conversation to remember your word and previous guesses
What you can do is to instruct it to type out the word, in some language that you don't know at all, making it available in the context while also effectively hidden from you. Simpler than printing it to a file.