【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
得意时做事,失意时读书