GitHub user jovanni-hernandez edited a discussion: Mutual TLS with OpenAI 
Connection

Hi all, is there any way to use the OpenAI Connection with a client certificate 
for Mutual TLS? 

>From reading the docs for the OpenAI python client that the Connection uses, 
>it seems like I'd need to create a new HTTPX client that is configured with 
>the client certificate, and use the Connection extra field to pass it down to 
>the OpenAI python client. I gave this a go to try to fetch the URI to add via 
>the CLI or WebUI, but the string comes back as an object. Is this even 
>supported?

```python
import ssl
from airflow.sdk import Connection
import httpx
from openai import Client, DefaultHttpxClient

ctx = ssl.create_default_context()
ctx.load_cert_chain(
     certfile="path/to/client.pem"
 ) 

client = httpx.Client(verify=ctx)

c = Connection(
    conn_id="some_conn",
    conn_type="openai",
    host="myhost.com",
    extra={"openai_client_kwargs": {"http_client": client}},
)

print(c.get_uri())
```
```
openai://myhost.com/?__extra__=%7B%27openai_client_kwargs%27%3A+%7B%27http_client%27%3A+%3Chttpx.Client+object+at+0x7f132c5f7fd0%3E%7D%7D
```

GitHub link: https://github.com/apache/airflow/discussions/53244

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscr...@airflow.apache.org

Reply via email to