Azure with Mistral

Hello,

do someone has ever setup Mistral deployed on Azure for embedding ?

Because when i’m using the provider azure_openai, it request the OPENAI_API-KEY, even though I use mistral.

And if i use mistralai it request MISTRAL_API_KEY which is not the one provided by Azure.

litellm.exceptions.AuthenticationError: litellm.AuthenticationError: AuthenticationError: OpenAIException - Error code: 401 - {‘error’: {‘message’: ‘Incorrect API key provided: ***********. You can find your API key at https://platform.openai.com/account/api-keys.’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘invalid_api_key’}}

this is my config :

pdf_search_tool = PDFSearchTool(
pdf=pdf_file_path,
config=dict(
llm=dict(
provider=“azure_openai”,
config=dict(
model=model_llm,
),
),
embedder=dict(
provider=“azure_openai”,
config=dict(
model=model_embedding,
api_base=os.getenv(“AZURE_OPENAI_ENDPOINT”),
),
),
),
)

First things first, it’s important to remember that CrewAI uses the EmbedChain library under the hood for its tools. So the configuration pattern for your tool should follow the EmbedChain standard.

I recommend taking a look at the EmbedChain documentation, especially where it discusses the Azure OpenAI embedding model. Adapting the example from the documentation, your code would look something like this:

from crewai_tools import PDFSearchTool
import os

os.environ["OPENAI_API_TYPE"] = "azure"
os.environ["OPENAI_API_VERSION"] = "<XXX>"
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://<XXX>.openai.azure.com/"
os.environ["AZURE_OPENAI_API_KEY"] = "<XXX>"

pdf_source_file_path = "<YOUR_PDF_PATH>"

rag_llm = {
    "provider": "azure_openai",
    "config": {
        "model": "<YOUR_LLM_MODEL_NAME>",
        "deployment_name": "<YOUR_LLM_DEPLOYMENT_NAME>",
        "temperature": 0.2
    }
}
rag_embedder = {
    "provider": "azure_openai",
    "config": {
        "model": "<YOUR_EMBEDDING_MODEL_NAME>",
        "deployment_name": "<YOU_EMBEDDING_MODEL_DEPLOYMENT_NAME>",
    }
}

pdf_search_tool = PDFSearchTool(
    pdf=pdf_source_file_path,
    config={
        "llm": rag_llm,
        "embedder": rag_embedder
    }
)

Hello,

I tried with your recommendations but i still have an error with the API key.

when I use azure_openai it use by default OPEN API key so I have the error : “Incorrect API key provided”. because it’s an Azure key