diff --git a/examples/async_chat_with_image_no_streaming.py b/examples/async_chat_with_image_no_streaming.py new file mode 100755 index 0000000..22f9adc --- /dev/null +++ b/examples/async_chat_with_image_no_streaming.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import asyncio +import os + +import httpx + +from mistralai import Mistral +from mistralai.models import ImageURLChunk, TextChunk, UserMessage + + +async def main(): + api_key = os.environ["MISTRAL_API_KEY"] + model = "pixtral-12b" + client = Mistral(api_key=api_key) + + chat_response = await client.chat.complete_async( + model=model, + messages=[ + UserMessage( + content=[ + {"type": "text", "text": "What's in this image?"}, + { + "type": "image_url", + "image_url": "https://mistral.ai/images/news/codestral/FIM_table.png", + }, + ] + ) + ], + ) + + print(chat_response.choices[0].message.content) + + +if __name__ == "__main__": + asyncio.run(main())