Skip to content
Project: Planning a Trip to Paris with the OpenAI API
  • AI Chat
  • Code
  • Report
  • As a distinguished AI Developer, you've been selected by Peterman Reality Tours, an internationally acclaimed tourism company, to undertake an influential project. This project requires you to harness the potential of OpenAI's API, specifically using its state-of-the-art language model, GPT-3.5 Turbo, to create an AI-powered travel guide for the culturally rich city of Paris.

    Your creation will become a virtual Parisian expert, delivering valuable insights into the city's iconic landmarks and hidden treasures. The AI will respond intelligently to a set of common questions, providing a more engaging and immersive travel planning experience for the clientele of Peterman Reality Tours.

    The ultimate aspiration is a user-friendly, AI-driven travel guide that significantly enhances the exploration of Paris. Users will be able to pre-define their questions and receive well-informed answers from the AI, providing a seamless and intuitive travel planning process.

    Before you start

    In order to complete the project you will need to create a developer account with OpenAI and store your API key as an environment variable. Instructions for these steps are outlined below.

    Create a developer account with OpenAI

    1. Go to the API signup page.

    2. Create your account (you'll need to provide your email address and your phone number).

    1. Go to the API keys page.

    2. Create a new secret key.

    1. Take a copy of it. (If you lose it, delete the key and create a new one.)

    Add a payment method

    OpenAI sometimes provides free credits for the API, but this can vary based on geography. You may need to add debit/credit card details.

    Using the gpt-3.5-turbo model in this project should incur a cost less than 1 US cent (but if you rerun tasks, you will be charged every time). For more information on pricing, see OpenAI's pricing page.

    1. Go to the Payment Methods page.

    2. Click Add payment method.

    1. Fill in your card details.

    Add an environment variable for your OpenAI key

    1. In the Workbook, click on "Environment," in the left sidebar.

    2. Click on the plus button next to "Environment variables" to add environment variables.

    3. In the "Name" field, type "OPENAI". In the "Value" field, paste in your secret key.

    1. Click "Create", then you'll see the following pop-up window. Click "Connect," then wait 5-10 seconds for the kernel to restart, or restart it manually in the Run menu.
    import os
    open_ai = os.environ["OPEN_AI"]
    # Start your code here!
    import os
    from openai import OpenAI
    # Define the model to use
    model = "gpt-3.5-turbo"
    # Define the client
    client = OpenAI(api_key=os.environ["OPENAI"])
    # Define the conversation
    conversation =[
            "role": "system",
            "content":"You are a travel guide designed to provide information about landmarks that tourists should explore in Paris. You speak in a concise manner."
            "content":"What is the most famous landmark in Paris?"
            "content":"The most famous landmark in Paris is the Eiffel Tower."
    # Define a list of questions
    questions = [
        "How far away is the Louvre from the Eiffel Tower (in driving miles)?",
        "Where is the Arc de Triomphe?",
        "What are the must-see artworks at the Louvre Museum?",
    # Loop through each question to generate responses
    for question in questions:
        # Format the user input into dictionary form
        input_dict = {"role": "user", "content": question}
        # Add the user input dictionary to the conversation
        # Make the next API call
        response =
        # Print the response from the model
        resp = response.choices[0].message.content
        # Convert the response into the dictionary
        resp_dict = {"role": "assistant", "content": resp}
        # Append the response to the conversation