When using Foundation Models, is it possible to ask the model to produce output in a specific language, apart from giving an instruction like "Provide answers in <some language>." ? (I tried that and it kind of worked, but it seems fragile.)
I haven't noticed an API to do so and have a use-case where the output should be in a user-selectable language that is not the current system language.
First, check that your target language is supported by Apple Intelligence for this to work.
Next, what you'll want to do is first get the language/locale minimum identifier, of your target language, which should look something like "en-US", "fr", "en-AU", etc.
Now in the LanguageModelSession instructions, set the instructions to be "The user's locale is en-AU"
(replacing en-AU with your locale code). This special phrase should work a bit more reliably than "Provide answers in <some language>" because of the way the model has been trained. This verbatim phrase should be at the start of your instructions, and you can add any custom instructions after that as you like.