First, grab the API keys

Portkey API KeyOpenAI API Key
pip install -qU portkey-ai openai

Let’s make a request

from openai import OpenAI

from portkey_ai import PORTKEY_GATEWAY_URL, createHeaders

portkey = OpenAI(

    api_key = 'OPENAI_API_KEY',

    base_url = PORTKEY_GATEWAY_URL,

    default_headers = createHeaders(

        provider = "openai",

        api_key = 'PORTKEY_API_KEY'

    )

)

emotions = portkey.chat.completions.create(

    model = "gpt-4o",

    messages = [{"role": "user","content":

        [

            {"type": "image_url","image_url": {"url": "https://i.insider.com/602ee9d81a89f20019a377c6?width=1136&format=jpeg"}},

            {"type": "text","text": "What expression is this person expressing?"}

        ]

    }

  ]

)

print(emotions.choices[0].message.content)

Get Observability over the request