【python】openai 配置代理

OpenAI() 初始化的时候设置 http_client 参数即可

import os
import httpx
from openai import OpenAI

proxies = {
    'http://': 'http://127.0.0.1:xxxx',
    'https://': 'http://127.0.0.1:xxxx'
}

httpx_client = httpx.Client(proxies=proxies)
client = OpenAI(http_client=httpx_client)
models = client.models.list()
print(models)

 

 

参考文献:https://blog.csdn.net/SHELLCODE_8BIT/article/details/139323504

posted @ 2024-07-26 16:00  蓝色星辰1993  阅读(94)  评论(0编辑  收藏  举报