Exercises the audio-input branch of MistralClient.IChatClient end-to-end by:
1. Using Mistral TTS (/v1/audio/speech) to synthesize a short utterance.
2. Sending that audio to a Voxtral chat model (default
voxtral-small-latest) as a Meai.DataContent with media type
audio/wav, alongside a text prompt asking the model to repeat what it
heard.
3. Asserting the model returns text that mentions the original utterance.
Skips when MISTRAL_API_KEY is unset, the account has no voices, the TTS
endpoint refuses the request, or the Voxtral chat model isn't enabled for
this account.
This example assumes using Mistral; is in scope and apiKey contains your Mistral API key.
usingvarclient=newMistralClient(apiKey);VoiceListResponsevoices;try{voices=awaitclient.AudioVoices.ListAllVoicesAsync();}catch(ApiExceptionex){thrownewAssertInconclusiveException($"Mistral voice listing unavailable (HTTP {(int?)ex.StatusCode}); skipping live chat-with-audio test.",ex);}if(voices.Itemsisnot{Count:>0}items){thrownewAssertInconclusiveException("No voices available on this Mistral account; skipping live chat-with-audio test.");}conststringutterance="The quick brown fox jumps over the lazy dog.";SpeechResponsespeech;try{speech=awaitclient.AudioSpeech.SpeechAsync(newSpeechRequest{Input=utterance,VoiceId=items[0].Id.ToString(),ResponseFormat=SpeechOutputFormat.Wav,});}catch(ApiExceptionex){thrownewAssertInconclusiveException($"Mistral TTS unavailable for this account (HTTP {(int?)ex.StatusCode}); skipping live chat-with-audio test.",ex);}varaudioBytes=Convert.FromBase64String(speech.AudioData);Meai.IChatClientchatClient=client;Meai.ChatResponseresponse;try{response=awaitchatClient.GetResponseAsync([ new Meai.ChatMessage(Meai.ChatRole.User, [ new Meai.TextContent("Repeat exactly what the speaker said in the audio, with no extra commentary."), new Meai.DataContent(audioBytes, mediaType: "audio/wav"), ]),],newMeai.ChatOptions{ModelId=VoxtralChatModelId,});}catch(ApiExceptionex)when(ex.StatusCodeisSystem.Net.HttpStatusCode.NotFoundorSystem.Net.HttpStatusCode.ForbiddenorSystem.Net.HttpStatusCode.BadRequest){thrownewAssertInconclusiveException($"Voxtral chat model '{VoxtralChatModelId}' not enabled for this account (HTTP {(int?)ex.StatusCode}); skipping live chat-with-audio test.",ex);}