OpenAI

Chat with the OpenAI model about images from URLs in Python

Learn to use the OpenAI API for creating chat completions with text and images from URLs in Python. This recipe includes crafting API requests with user messages, setting a token limit, and printing the response content. Follow these steps to effectively integrate text and image inputs into your chat interactions.

Required packages

You need below packages to use the code generated by recipe. All packages are automatically installed in MLJAR Studio.

openai>=1.35.14

Interactive recipe

You can use below interactive recipe to generate code. This recipe is available in MLJAR Studio.

In the below recipe, we assume that you have following variables available in your notebook:

  • client (type OpenAI)

Python code

# Python code will be here

Code explanation

  1. Create the API request.
  2. Print the response.

Example Python notebooks

Please find inspiration in example notebooks