Repository: confident-ai/deepeval
Issue: GPTModel does not support separate sync and async HTTP clients
Root cause: Architectural Constraint

# GPTModel does not support separate sync and async HTTP clients

## Description

`GPTModel` currently passes the same `http_client` kwargs to both `OpenAI` (sync) and `AsyncOpenAI` (async) clients, making it impossible to use custom HTTP clients that require different instances for sync vs async operations.

This is problematic when using authentication libraries or proxies that provide separate sync (`httpx.Client`) and async (`httpx.AsyncClient`) implementations.

## Environment

- **DeepEval version**: 3.7.2
- **Python version**: 3.10.14
- **OpenAI SDK**: 2.8.1

## The Problem

I need to create a custom `GPTModel` for evaluation because I'm using a custom OpenAI-compatible endpoint (`base_url`) that requires custom authentication. This authentication is implemented via a custom `httpx` client.

My authentication library provides two separate HTTP clients:
- **Sync client** (extends `httpx.Client`) for synchronous operations
- **Async client** (extends `httpx.AsyncClient`) for asynchronous operations

### Issue 1: Using async client directly fails

When I try to pass the async client to `GPTModel`:

```python
evaluation_model = GPTModel(
    model="gpt-4o-mini",
    base_url=custom_gateway_url,
    http_client=async_http_client,  # AsyncClient instance
)
```

I get this error during initialization:

```
TypeError: Invalid `http_client` argument; Expected an instance of `httpx.Client`
but got <class 'httpx.AsyncClient'>
```

This happens because `GPTModel` initializes the **sync** `OpenAI` client first (in `load_model()` with `async_mode=False` by default), and it validates that `http_client` is an `httpx.Client`, not an `httpx.AsyncClient`.

### Issue 2: Using sync client forces all evaluations to run synchronously

When I use the sync client to avoid the error:

```python
evaluation_model = GPTModel(
    model="gpt-4o-mini",
    base_url=custom_gateway_url,
    http_client=sync_http_client,  # Client instance
)
```

The model initializes successfully, but I must disable async mode everywhere:

```python
metric = AnswerRelevancyMetric(
    model=evaluation_model,
    async_mode=False,  # Required
)

evaluate(
    test_cases=test_cases,
    metrics=[metric],
    async_config=AsyncConfig(run_async=False)  # Required
)
```

If I try to enable async evaluation with the sync client, the async `AsyncOpenAI` client fails because it receives an `httpx.Client` instead of an `httpx.AsyncClient`.

### Root Cause (I think)

In `deepeval/models/llms/openai_model.py`, the `_build_client()` method passes the same kwargs to both client types:

```python
def _build_client(self, cls):
    kw = dict(
        api_key=api_key,
        base_url=self.base_url,
        **self._client_kwargs(),  # Same kwargs for both sync and async
    )
    return cls(**kw)
```

The OpenAI SDK requires:
- **Sync client** (`OpenAI`): `http_client: httpx.Client`
- **Async client** (`AsyncOpenAI`): `http_client: httpx.AsyncClient`

Because `GPTModel` only accepts a single `http_client` parameter, there's no way to provide both client types.

---

Would appreciate guidance on whether a pull request addressing this issue would be welcome, and if so, any preferred approach for the implementation.


Thank you for raising this @gchaperon, I will be looking into it.

We are having the same issue on our side because we need to skip certificate SSL verification with the following model declaration :

```python
model = LocalModel(
    model="mistral-small-2506",
    api_key="redacted",
    base_url="https://litellm.local/v1/",
    temperature=0.1,
    http_client=httpx.AsyncClient(verify=False),
)
```