Add async support for mistral embeddings
diff --git a/llama_index/embeddings/mistralai.py b/llama_index/embeddings/mistralai.py
index 995ad17166924..2bd444859f280 100644
--- a/llama_index/embeddings/mistralai.py
+++ b/llama_index/embeddings/mistralai.py
@@ -5,6 +5,7 @@
 from llama_index.bridge.pydantic import PrivateAttr
 from llama_index.callbacks.base import CallbackManager
 from llama_index.embeddings.base import DEFAULT_EMBED_BATCH_SIZE, BaseEmbedding
+from llama_index.llms.generic_utils import get_from_param_or_env
 
 
 class MistralAIEmbedding(BaseEmbedding):
@@ -19,6 +20,7 @@ class MistralAIEmbedding(BaseEmbedding):
 
     # Instance variables initialized via Pydantic's mechanism
     _mistralai_client: Any = PrivateAttr()
+    _mistralai_async_client: Any = PrivateAttr()
 
     def __init__(
         self,
@@ -29,12 +31,21 @@ def __init__(
         **kwargs: Any,
     ):
         try:
+            from mistralai.async_client import MistralAsyncClient
             from mistralai.client import MistralClient
         except ImportError:
             raise ImportError(
                 "mistralai package not found, install with" "'pip install mistralai'"
             )
+        api_key = get_from_param_or_env("api_key", api_key, "MISTRAL_API_KEY", "")
+
+        if not api_key:
+            raise ValueError(
+                "You must provide an API key to use mistralai. "
+                "You can either pass it in as an argument or set it `MISTRAL_API_KEY`."
+            )
         self._mistralai_client = MistralClient(api_key=api_key)
+        self._mistralai_async_client = MistralAsyncClient(api_key=api_key)
         super().__init__(
             model_name=model_name,
             embed_batch_size=embed_batch_size,
@@ -56,7 +67,15 @@ def _get_query_embedding(self, query: str) -> List[float]:
 
     async def _aget_query_embedding(self, query: str) -> List[float]:
         """The asynchronous version of _get_query_embedding."""
-        return self._get_query_embedding(query)
+        return (
+            (
+                await self._mistralai_async_client.embeddings(
+                    model=self.model_name, input=[query]
+                )
+            )
+            .data[0]
+            .embedding
+        )
 
     def _get_text_embedding(self, text: str) -> List[float]:
         """Get text embedding."""
@@ -68,7 +87,15 @@ def _get_text_embedding(self, text: str) -> List[float]:
 
     async def _aget_text_embedding(self, text: str) -> List[float]:
         """Asynchronously get text embedding."""
-        return self._get_text_embedding(text)
+        return (
+            (
+                await self._mistralai_async_client.embeddings(
+                    model=self.model_name, input=[text]
+                )
+            )
+            .data[0]
+            .embedding
+        )
 
     def _get_text_embeddings(self, texts: List[str]) -> List[List[float]]:
         """Get text embeddings."""
@@ -79,4 +106,7 @@ def _get_text_embeddings(self, texts: List[str]) -> List[List[float]]:
 
     async def _aget_text_embeddings(self, texts: List[str]) -> List[List[float]]:
         """Asynchronously get text embeddings."""
-        return self._get_text_embeddings(texts)
+        embedding_response = await self._mistralai_async_client.embeddings(
+            model=self.model_name, input=texts
+        )
+        return [embed.embedding for embed in embedding_response.data]
diff --git a/llama_index/llms/mistral.py b/llama_index/llms/mistral.py
index 8a47b862980a1..e72f22fc488a0 100644
--- a/llama_index/llms/mistral.py
+++ b/llama_index/llms/mistral.py
@@ -104,9 +104,7 @@ def __init__(
         additional_kwargs = additional_kwargs or {}
         callback_manager = callback_manager or CallbackManager([])
 
-        api_key = api_key = get_from_param_or_env(
-            "api_key", api_key, "MISTRAL_API_KEY", ""
-        )
+        api_key = get_from_param_or_env("api_key", api_key, "MISTRAL_API_KEY", "")
 
         if not api_key:
             raise ValueError(

# Description

PR to add async support for mistral embeddings and syntax fix for mistral llm.

Fixes # (issue)

## Type of Change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Added new unit/integration tests
- [ ] Added new notebook (that tests end-to-end)
- [x] I stared at the code and made sure it makes sense

# Suggested Checklist:

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added Google Colab support for the newly added notebooks.
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] I ran `make format; make lint` to appease the lint gods
