# Check if PHOENIX_API_KEY is present in the environment variables.# If it is, we'll use the cloud instance of Phoenix. If it's not, we'll start a local instance.# A third option is to connect to a docker or locally hosted instance.# See https://docs.arize.com/phoenix/setup/environments for more information.# Launch Phoeniximport osif"PHOENIX_API_KEY"in os.environ: os.environ["PHOENIX_CLIENT_HEADERS"]=f"api_key={os.environ['PHOENIX_API_KEY']}" os.environ["PHOENIX_COLLECTOR_ENDPOINT"]="https://app.phoenix.arize.com"else:import phoenix as px px.launch_app().view()# Connect to Phoenixfrom phoenix.otel import registertracer_provider =register()# Instrument OpenAI calls in your applicationfrom openinference.instrumentation.openai import OpenAIInstrumentorOpenAIInstrumentor().instrument(tracer_provider=tracer_provider, skip_dep_check=True)# Make a call to OpenAI with an image providedfrom openai import OpenAIclient =OpenAI()response = client.chat.completions.create( model="gpt-4o", messages=[ {"role": "user","content": [ {"type": "text", "text": "What’s in this image?"}, {"type": "image_url","image_url": {"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", }, }, ], } ], max_tokens=300,)