Guide to Using Chat GPT for Real Estate Descriptions Automation

An AI-generated image of a modern robot at a desk, typing real estate descriptions on a laptop, showcasing AI's role in real estate marketing
An AI-generated image of a modern robot at a desk, typing real estate descriptions on a laptop, showcasing AI's role in real estate marketing

Creating compelling real estate descriptions can be a time-consuming task. This tutorial demonstrates how to automate this process using the ChatGPT API, leveraging data from Places API to craft descriptions that highlight key amenities and locational advantages of properties.

Requirements:

  • Geoapify account to access to Places API
  • Access to OpenAI's ChatGPT API. Please note, you will need to add a minimum of 5$ to your account to enable running the API from your code.
  • Basic knowledge of programming (Python or Javascript)

Step 1: Using the OpenAI Playground to define ChatGPT API Requests

ChatGPT, developed by OpenAI, is a sophisticated language model capable of generating human-like text. To utilize it for automating real estate property descriptions, some customization is necessary to ensure outputs are suitable for machine processing, for example, are returned in JSON format.

This first step involves using the OpenAI Playground to fine-tune ChatGPT, adjusting parameters to tailor its responses for real estate needs. This setup will help ensure that the descriptions are formatted correctly, meeting the specific demands of real estate listings and database integration.

Let's explore how to configure ChatGPT API requests to achieve optimal results in real estate applications.

Accessing the OpenAI Playground

Instructions:

  • Visit the OpenAI Website: Start by navigating to OpenAI's official website.
  • Log In or Sign Up: If you already have an account, click on the 'Log In' button. If not, select 'Sign Up' to create a new account. Follow the prompts to complete the registration or login process.
  • Select the "API" option You should select the “API” option to proceed with integrating ChatGPT API
    Choose ChatGPT API
  • Navigate to the Playground: Once logged in, locate the navigation menu. Look for the 'Playground' option, which is typically found in the top menu or under a specific section like 'Products' or 'Tools'. Click on 'Playground' to enter the environment where you can start experimenting with the API.
    Open Playground

Understanding the ChatGPT API Playground Interface

The Playground helps you generate the JSON structure required for the API request by allowing you to simulate the conversation flow between the user and the assistant. Here is an example of Chat GPT API request in JSON format:

{
  "model": "gpt-3.5-turbo",
  "messages": [
    {
      "role": "system",
      "content": "You are a knowledgeable real estate assistant capable of writing descriptive and appealing property listings based on specific features provided by a user."
    },
    {
      "role": "user",
      "content": "I need a description for a listing, can you help?"
    },
    {
      "role": "assistant",
      "content": "Of course! Please provide me with the details of the property you'd like to list."
    },
    {
      "role": "user",
      "content": "It's a 4-bedroom house in the suburbs with a big backyard and a swimming pool. I want to highlight the newly renovated kitchen and the proximity to good schools."
    },
    {
      "role": "assistant",
      "content": "Sure, here's a draft description for your listing: Nestled in a serene suburban neighborhood, this spacious 4-bedroom home offers a perfect blend of comfort and convenience. Enjoy family time in the expansive backyard with its sparkling swimming pool, or cook up gourmet meals in the newly renovated kitchen. With top-rated schools just a short drive away, this home is an ideal choice for families seeking a harmonious lifestyle."
    },
    {
      "role": "user",
      "content": "That's a good start, but can you make it sound a bit more luxurious and emphasize the high-end finishes in the kitchen?"
    }
  ]
}

The Playground is designed to experiment with and understand how the model responds to various inputs before deploying it in an application:

Understanding Chat GPT API Playground interface

When crafting an API request in the OpenAI Playground, your interaction will consist of a series of messages that simulate a conversation. To effectively use the API, your request should follow a structured format that includes a clear definition of roles and a sequenced exchange of messages.

  • System Message: Begin your API request with a single message assigned the "system" role. This message should not ask for a task to be completed; instead, it provides context to the ChatGPT model. It explains the assistant's role and offers necessary background information. For instance, in the context of real estate, the system message might inform ChatGPT that it will be acting as a real estate expert tasked with generating property descriptions based on certain data points.
  • Assistant and User Messages: After setting the stage with your system message, you will compose a series of messages with alternating "assistant" and "user" roles. These messages represent the back-and-forth of a conversation, with the "user" role simulating the input from a human user and the "assistant" role simulating the AI's response.
    • The "user" messages will include the requests or questions directed at the AI, such as asking for a description of a property with certain features.
    • The "assistant" messages will then be the AI's responses, which, in practice, you won't provide yourself but will be generated by the AI as it processes the conversation.
  • Last Message as 'User' Role: The final message in your API request should be a "user" role message, which contains the prompt for the actual task you want the AI to perform. In the real estate description scenario, this would be the detailed information about the property that you want the AI to describe.

On the right of the Playground interface, you'll see various parameters you can adjust. These include:

  • Model: Specifies the version of the AI you are using, which in this case, is "gpt-3.5-turbo".
  • Temperature: Controls the creativity of the AI. A lower temperature results in more predictable text, while a higher temperature generates more varied outputs.
  • Max Tokens: Determines the length of the output. For a real estate description, you might want to set this to a number that produces a few descriptive sentences.
  • Stop sequences: Are particularly useful when you want the model to stop generating further content once it hits a certain word or phrase that signifies the end of a complete thought or section.
  • Top P: Influences the diversity of the AI’s responses. A lower value means the model is more confident, higher values allow more variability in responses.
  • Frequency Penalty: Adjust this to prevent the AI from repeating itself.
  • Presence Penalty: Change this to encourage the AI to introduce new concepts throughout the description.

Tuning ChatGPT Requests for Real Estate Listings

Writing an effective system message is crucial for automating descriptions using an AI like ChatGPT. This message sets the tone and scope of the AI's task, ensuring it understands exactly what's required. Here are some general recommendations to consider when crafting a system message for automating descriptions:

1. Be Clear and Specific
  • Define the Task Clearly: Clearly state the role and responsibilities you expect the AI to assume. Be explicit about the task, such as generating product descriptions, summarizing articles, or creating content for websites.
  • Detail the Requirements: Specify any particular requirements or constraints, like the length of the text, style, tone, and specific phrases or terminology that should be used.
2. Provide Context
  • Background Information: Include any necessary background information that helps the AI understand the context better. This might involve industry-specific details, target audience characteristics, or specific goals (e.g., SEO optimization).
  • Purpose of the Text: Explain what the generated text will be used for. This helps the AI tailor its responses to fit the intended use, whether it’s to inform, persuade, entertain, or convert.
3. Set Parameters Clearly
  • Formatting Guidelines: If the output needs to be formatted in a certain way (like JSON), specify this upfront. Outline what elements are needed, such as titles, headings, bullet points, or specific data fields.
  • Language and Style Preferences: Indicate if there’s a preferred writing style, such as formal, casual, technical, or conversational. Also, mention if the language should cater to a certain reading level or if it should include specific jargon.
4. Limitations and Boundaries
  • Constraints on Content: Clearly mark any limitations related to the content, such as avoiding certain topics, words, or exceeding a specific word count/chars.
  • Ethical Guidelines: If applicable, highlight any ethical considerations to keep in mind, such as avoiding biased language or adhering to privacy laws.

Let's apply the principles we've discussed by using a specific system message as an example to generate property descriptions. This exercise will involve leveraging data from the Geoapify Places API, which provides detailed information about places nearby, such as public transport stops, schools, leisure areas, and more.

Example

System Message

"You are a real estate expert tasked with generating property descriptions based on specific data points: proximity to the city center, kindergarten, school, public transport stops, leisure objects (parks, playgrounds), sports objects, etc., and the number of restaurants and supermarkets within 1000 (instead of 1000m, name it walking distance), within 5000m (instead of 5000m, name in within few minutes drive).

You return a description and your expected conclusion that tells which group this property is suitable for — "Urban Dwellers," "Suburban Families," "Rural Retreat Seekers," "City Professionals," or "Entertainment District Residents." Use only these groups with exact spelling.

You return the results in the following JSON format:

{
"title": string,
"description": string,
"recommendation": string[]
}

The maximum size of the title is 100 characters, the description is 500 characters, and the recommendation contains only the groups listed below."

User Message 1

"type: 4-room house, city center: 500m, school: 550m, bus stop: 150m, train stop: 1200m, park: 400m, restaurants_1000: 5, restaurants_5000: 12, supermarkerts_1000: 2, supermarkers_5000: 5"

Result 1
{
	"title": "Cozy 4-Room House in the Heart of the City",
	"description": "This charming 4-room house is located just 500m from the city center, with a school a short walk away at 550m. The proximity to public transport is excellent, with a bus stop just 150m away and a train stop within reach at 1200m. Enjoy leisurely strolls in the park only 400m away. For dining options, there are 5 restaurants within walking distance and a total of 12 within few minutes drive. You can also find 2 supermarkets nearby and 5 within a short drive. ",
	"recommendation": ["Urban Dwellers"]
}
User Message 2

"type: 5-room apartment, city center: 3500m, school: 120m, bus stop: 50m, underground: 400m, playground: 130m, restaurants_1000: 3, restaurants_5000: 20, supermarkerts_1000: 3, supermarkers_5000: 10"

Result 2
{
"title": "Spacious 5-Room Apartment with Proximity to City Center",
"description": "This spacious 5-room apartment is conveniently located just 3500m from the city center, with a school only 120m away. Public transport options are easily accessible, with a bus stop just 50m away and an underground station 400m away. Families will appreciate the close proximity to a playground located just 130m away. The neighborhood also offers a variety of dining options, with 3 restaurants within walking distance and 20 restaurants within a few minutes' drive. Additionally, there are 3 supermarkets within walking distance and 10 supermarkets within a few minutes' drive.",
"recommendation": ["Suburban Families", "City Professionals"]
}
User Message 3

"type: 4-room townhouse, city center: 3000m, school: 300m, bus stop: 230m, underground: 1400m, playground: 500m, restaurants_1000: 2, restaurants_5000: 10, supermarkerts_1000: 1, supermarkers_5000: 12"

Result 3
{
"title": "Modern 4-Room Townhouse in Central Location",
"description": "This stylish 4-room townhouse is conveniently located in the heart of the city, just 3000m from the city center. Situated within walking distance to a school (300m), bus stop (230m), and underground station (1400m), it offers easy access to transportation and educational facilities. Additionally, the property is surrounded by a playground (500m), 2 restaurants within walking distance, and 10 restaurants within a few minutes' drive. With 1 supermarket within walking distance and 12 supermarkets within a short drive, daily errands are a breeze.",
"recommendation": ["Urban Dwellers", "City Professionals"]
}

We provided several examples of property descriptions generated using the ChatGPT model. It's important to note that these examples serve purely as illustrations and may contain inconsistencies or lack specific details relevant to actual properties. Additionally, these descriptions were generated using the default parameters of the ChatGPT API.

To tailor the descriptions more closely to your specific needs, we encourage experimenting with various API parameters. Adjusting settings such as the temperature, max_tokens, top_p, and others can significantly alter the style, detail, and creativity of the generated content. By tweaking these parameters, you can optimize the output to better match the tone, complexity, and formatting required for your real estate listings or other descriptive tasks.

Step 2: Preparing Data for ChatGPT Using the Geoapify Places API

Now, let's explore how to prepare data for a ChatGPT API call using the Geoapify Places API to gather information about places and amenities nearby. The Geoapify Places API supports searches across more than 400 categories, making it incredibly versatile for real estate applications.

It allows you to tailor your search based on bias proximity and returns the distance in meters from the provided location to each place.

Here are examples of categories that may be relevant for generating property descriptions:

CategoryDescription
commercial.supermarketLocations of supermarkets where groceries and household goods are sold
commercial.shopping_mallAreas encompassing a variety of retail stores and services
catering.restaurantEstablishments that serve full meals in a formal setting
catering.fast_foodQuick service restaurants offering fast food options
catering.cafeSmall, casual eateries serving coffee and light snacks
catering.barVenues primarily serving alcoholic beverages with a social atmosphere
catering.pubEstablishments offering a mix of drinks and meals, typically informal
education.schoolEducational institutions for children and teenagers
childcare.kindergartenFacilities providing care and education for young children
entertainmentVenues and locations offering recreational and leisure activities
healthcareMedical centers, hospitals, clinics, and pharmacies
highway.motorwayMajor roads designed for fast traffic, with limited access
highway.trunkImportant roads that aren't motorways but link major towns
leisure.parkPublic areas with green space for recreation and relaxation
leisure.playgroundOutdoor areas designed for children to play
public_transportLocations of bus stops, train stations, and other transport hubs
populated_place.hamletSmall and often rural settlements with limited population
populated_place.villageLarger than a hamlet but smaller than a town, typically rural
populated_place.townAn urban area with a population larger than a village but smaller than a city
populated_place.cityLarge and densely populated urban areas with extensive services

When utilizing the Geoapify Places API for gathering information about amenities and locations around a property, you can split your API requests into two distinct types:

  • Querying for the Closest Place: This type of request focuses on finding the single nearest facility or amenity in a specific category. For example, you might query for the closest supermarket, school, or public transport hub to provide a potential buyer or tenant with the exact distance to the most accessible option. This is particularly useful for emphasizing convenience and accessibility in property descriptions.

For example, to find the closest supermarket to a property located at specific latitude and longitude coordinates, you could structure your API request like this:

https://api.geoapify.com/v2/places?categories=commercial.supermarket&bias=proximity:4.0616133,49.2505929&filter=circle:4.0616133,49.2505929,1000&limit=1&apiKey=YOUR_API_KEY
  • Querying for the Number of Places Within a Certain Distance: This approach involves counting how many facilities or amenities fall within a specified radius from the property. This type of query is useful for showcasing the variety and abundance of options available near the property, such as the number of cafes, parks, or healthcare facilities within walking distance or a short drive. It helps to illustrate the level of community resources and lifestyle convenience the area offers.

To count how many cafes are within a 500-meter radius of a property, the API request might look like this:

https://api.geoapify.com/v2/places?categories=catering.cafe&filter=circle:34.052235,-118.243683,500&limit=100&apiKey=YOUR_API_KEY

Each type of request serves different purposes in property description generation and can be strategically used to highlight various aspects of a property’s location and surrounding amenities. By carefully choosing which type of query to use based on what you wish to emphasize about a property, you can tailor your descriptions to appeal more strongly to potential buyers or renters' specific needs and interests.

Here's a JSFiddle link where you can find a code sample that demonstrates how to retrieve nearby places for a provided location using the Geoapify Places API. This example will help you understand how to structure your requests to gather detailed information about amenities and facilities around a property, which can enhance your real estate descriptions.

View the JSFiddle code sample for fetching nearby places

Please note, you will need to replace placeholders with actual values, such as your API key and the specific coordinates for the location you're interested in, to make the code operational for your specific needs. This example provides a practical starting point for integrating location-based data into your applications.

Step 3: Calling the ChatGPT API

Once you have prepared your data using the Geoapify Places API and structured your request, the next step is to call the ChatGPT API to generate your property descriptions. This step requires you to have an API key and sufficient funds in your account to access the OpenAI services.

Obtaining an API Key and Funding Your Account

  • API Key: To use the ChatGPT API, you first need to obtain an API key from OpenAI. This key will authenticate your requests to the API.

    Create an API Key

  • Adding Funds: As of May 1, 2024, you will need to have a minimum of $5 in your OpenAI account to begin making API calls. Ensure you add funds to your account to avoid interruptions.

It's crucial to remember that your OpenAI API key is a sensitive piece of information that authenticates your access to OpenAI services. It should be protected diligently and never published or shared publicly. Exposing your API key can lead to unauthorized use, which might result in unexpected charges and potential misuse of your OpenAI services. Always keep your API key confidential, and follow best practices for securing sensitive data:

  1. Store Securely: Keep your API key in a secure location. Avoid hardcoding it directly in your source code, especially if the code is stored in version control systems accessible by others or made public.
  2. Environment Variables: Use environment variables to manage your API keys. This approach keeps the key out of your source code and adds an extra layer of security by leveraging the operating system's management of environments.
  3. Access Controls: Restrict the access to your API key as much as possible. If you are working in a team environment, ensure that only those who absolutely need the key have access to it.
  4. Rotate Keys Regularly: Regularly update and rotate your API keys to minimize the risks associated with key leakage.

By adhering to these security practices, you can help safeguard your API key and protect your applications from unauthorized access.

Code Samples

Below is a JavaScript code sample that demonstrate how to structure and send a request to the ChatGPT API using JavaScript. Replace the placeholders with your actual API key, prompt, and other relevant data.

import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const response = await openai.chat.completions.create({
  model: "gpt-3.5-turbo",
  messages: [
    {
      "role": "system",
      "content": "You are a real estate expert tasked with generating property descriptions based on certain data points:  proximity to the city center, kindergarten, school, public transport stops, leisure objects (parks, playgrounds), sports objects, etc., and the number of restaurants and supermarkets within 1000 (instead of 1000m, name it walking distance), within 5000m (instead of 5000m, name in within few minutes drive).  You return a description and your expected conclusion that tells which group this property is suitable for —\"Urban Dwellers,\" \"Suburban Families,\" \"Rural Retreat Seekers,\" \"City Professionals,\" or \"Entertainment District Residents.\" Use only these groups with exact spelling.You return the results in the following JSON format: {\"title\": string,\"description\": string,\"recommendation\": string[]}The maximum size of the title is 100 characters, the description is 500 characters, and the recommendation contains only the groups listed below."
    },
    {
      "role": "user",
      "content": "{\"hamlet center\": \"1023m\",\"education.school\": \"183m\",\"childcare.kindergarten\": \"452m\",\"leisure.park\": \"150m\",\"leisure.playground\": \"253m\",\"public_transport.bus\": \"244m\",\"restaurants_1000\": 5,\"restaurants_5000\": \"many\",\"supermarket_1000\": 2,\"supermarket_5000\": \"many\"}"
    }
  ],
  temperature: 1,
  max_tokens: 256,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});

The code snippet provided uses the openai npm library, which is a Node.js package designed to facilitate interaction with the OpenAI API, specifically tailored for JavaScript and Node.js environments. This library allows developers to easily integrate and execute API requests to OpenAI services, including ChatGPT, directly from their JavaScript applications.

  1. Initialization: The script begins by importing the openai library and initializing an OpenAI client instance with an API key retrieved from environment variables, ensuring secure API usage.

  2. API Request Configuration:

    • Model Selection: The code specifies using the gpt-3.5-turbo model, which is designed for generating high-quality text completions.
    • Messages Setup: It constructs a conversation with a series of messages that define the roles of 'system', 'user', and 'assistant'. These messages outline the task (generating real estate descriptions) and provide contextual data points as well as pre-formulated assistant responses.
    • Role of System: Establishes the task context for the AI, describing its role as a real estate expert.
    • Role of User: Simulates a user providing specific property details such as distances to amenities and number of nearby facilities.
  3. API Request Execution:

    • Parameters Configuration: The request sets several parameters influencing the generation process:
      • temperature: Set to 1 to allow for maximum creativity.
      • max_tokens: Limits the response length to 256 tokens.
      • top_p: Controls the diversity of the response.
      • frequency_penalty and presence_penalty: Both set to 0, indicating no penalties for frequent or new information.
    • Sending the Request: The API call is made asynchronously using the await syntax, which waits for the completion to be created and then logs the response.
  4. Output Handling: The script handles the AI-generated descriptions by printing them to the console, allowing developers to see and evaluate the responses immediately.

This code demonstrates how to integrate and utilize the OpenAI API in a Node.js environment to automate the creation of detailed and contextually relevant property descriptions.

Conclusion

In conclusion, this tutorial demonstrated how to effectively automate property description generation using the Geoapify Places API and OpenAI's ChatGPT API.

We outlined the process of gathering detailed information about nearby amenities with Geoapify and then utilizing this data to generate engaging and accurate property descriptions through ChatGPT.

This integration showcases a practical application of AI in enhancing real estate listings, offering a streamlined approach to creating content that is both informative and appealing to potential clients. This method not only saves time but also enriches listings, potentially increasing engagement and satisfaction in the real estate market.