Repository: explodinggradients/ragas
Issue: Using another way to pass the OPENAI_API_KEY aside from the environment variable
Root cause: Documentation Deficiency

- [x] I have checked the [documentation](https://docs.ragas.io/) and related resources and couldn't resolve my bug.

**Describe the bug**
When I passed the OPENAI_API_KEY via the environment variable, everything was OK.
But if I passed the OPENAI_API_KEY like:

```python
openai_api_key = "sk-xxxxxxxxxx"
ragas_dataset = EvaluationDataset.from_list(ragas_list)
evaluator_llm = LangchainLLMWrapper(ChatOpenAI(model="gpt-4o", api_key=openai_api_key))
evaluator_embeddings = LangchainEmbeddingsWrapper(OpenAIEmbeddings(model="text-embedding-3-large", openai_api_key=openai_api_key))

metrics = [
    # LLMContextRecall(llm=evaluator_llm),  # retrieved_contexts required
    FactualCorrectness(llm=evaluator_llm),
    # Faithfulness(llm=evaluator_llm),  # retrieved_contexts required
    SemanticSimilarity(embeddings=evaluator_embeddings)
]
eval_result = evaluate(dataset=ragas_dataset, metrics=metrics)
```

The `evaluate` function will raise an error:

```
The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
```

Ragas version:  0.2.5
Python version:  3.11

**Code to Reproduce**
See above.

**Expected behavior**
Can be set the key in this way.

<!-- PS: bugs suck but is also part of the process. We sincerely apologies for breaking your flow because of it, but don't worry, we got your back ❤️. We will get this fixed as fast as we can and thanks for helping us out by reporting it 🙏. -->


If you do not pass your own defined llm and embedding when calling evaluate, then evaluate will automatically call OpenAI's model, which will result in an error.

you should do it like this.

results = evaluate(dataset=eval_dataset, metrics=metrics, llm=evaluator_llm, embeddings=embedding_model)

Thanks for replying @WKRZY.

> results = evaluate(dataset=eval_dataset, metrics=metrics, llm=evaluator_llm, embeddings=embedding_model)

This is a great way to work around this bug, but not the fix way. I already set the keys on the metrics. It seems that it didn't respect the keys on the metrics, and used the default LLM and embedding instances.
And another thing is if we change the `LangchainLLMWrapper` and `LangchainEmbeddingsWrapper` to the wrappers of LlamaIndex, the error will disappear.

hey @Icemap where you able to resolve this? sorry about the delay from our end

We bypassed this question, but didn't resolve it.

I'm not able to reproduce this @Icemap, checked with this
```py
from ragas.metrics import FactualCorrectness, SemanticSimilarity
from ragas import evaluate
from ragas.llms import LangchainLLMWrapper
from langchain_openai import ChatOpenAI
from langchain_openai import OpenAIEmbeddings
from ragas.embeddings import LangchainEmbeddingsWrapper

evaluator_llm = LangchainLLMWrapper(ChatOpenAI(model="gpt-4o", api_key=openai_api_key))
evaluator_embeddings = LangchainEmbeddingsWrapper(OpenAIEmbeddings(model="text-embedding-3-large", api_key=openai_api_key)) # change the api_key keyword-arg

metrics = [
    # LLMContextRecall(llm=evaluator_llm),  # retrieved_contexts required
    FactualCorrectness(llm=evaluator_llm),
    # Faithfulness(llm=evaluator_llm),  # retrieved_contexts required
    SemanticSimilarity(embeddings=evaluator_embeddings)
]
eval_result = evaluate(dataset=ragas_dataset, metrics=metrics)
```

it should be working fine as expected but do check at your end and let me know 🙂 

You are right. I tested and the bug is fixed. Kudos to you guys.

super glad to get hear it fixed 🥳