Get startedGet started for free

Using the tools parameter

You are developing an AI application for a real estate agency and have been asked to extract some key data from listings: house type, location, price, number of bedrooms. Use the Chat Completions endpoint with function calling to extract the information.

The message_listing message, containing the real estate listing, and function_definition, containing the function to call defined as a tool to be passed to the model, have been preloaded.

This exercise is part of the course

Developing AI Systems with the OpenAI API

View Course

Exercise instructions

  • Add the preloaded message, message_listing.
  • Add the function definition, function_definition.
  • Print the response.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

client = OpenAI(api_key="")

response= client.chat.completions.create(
    model="gpt-4o-mini",
    # Add the message
    ____,
    # Add your function definition
    ____
)

# Print the response
print(____)
Edit and Run Code