TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

Hello, I am using this code
import pandas as pd

import os

from openai import OpenAI

from dotenv import load_dotenv

import plotly.express as px

import seaborn as sns

import matplotlib.pyplot as plt

import numpy as np

Loading API key and organization ID from a dotenv file

load_dotenv(dotenv_path=‘apikey.env.txt’)

Retrieving API key and organization ID from environment variables

APIKEY = os.getenv(“APIKEY”)

Creating an instance of the OpenAI client with the provided API key and organization ID

client = OpenAI(

api_key=APIKEY

)
client

But when I execute, this message appear: TypeError: Client.init() got an unexpected keyword argument ‘proxies’

This is a mismatch between the httpx library and an older openai library package that uses a deprecated method.

A pip install --upgrade openai for the Python execution environment, getting and using the latest openai library module will likely resolve your issue.

Then don’t override the httpx client with your own use of the proxies parameter (a rare edge case).


The API will automatically use the default environment variable as your API key, and then you don’t have to do any work yourself.

client = OpenAI() # imports and uses OPENAI_API_KEY env var