Build a travel app with Claude 3
Here is a simple tutorial in which we will create a travel itinerary generator with the help of Anthropic Claude 3’s API and streamlit. For this, we will be using the latest Opus model, which according to Anthropic is better than GBT-4 in some cases. At the end of this tutorial, you will be able to have the code that generates a travel itinerary where possible places to visit, restaurants to eat, and activities to do are provided according to the user’s preference.

Prerequisites:
- Some background on Python and Streamlit.
- An API key for the open Anthropic Claude 3 platform.
Getting Started:
First, let’s create a new Streamlit app and import the necessary libraries:
import anthropic
st.title(‘Travel Itinerary Generator’)
Creating the Frontend:
Next, we will create the frontend of our app using Streamlit’s UI components. We will create four input fields: destination, number of days, budget level, and interests.
days = st.number_input(‘Number of Days:’, min_value=1)
budget_level = st.selectbox(‘Budget Level:’, [‘Low’, ‘Medium’, ‘High’])
interests = st.multiselect(‘Interests:’, [‘History and Culture’, ‘Nature and Outdoors’, ‘Food and Drink’, ‘Night Life’, ‘Shopping’, ‘Relaxation’])if st.button(‘Generate Itinerary’):
# Generate itinerary here

Creating the Backend:
Now, let’s create the backend of our app using Anthropic Claude 3’s API. First, we need to set up the client and define the system and user prompts.
# Set up the Anthropic Claude 3 client
anthropic.set_api_key(‘’)# Define the system prompt
system_prompt = “””
You are an expert tour guide for a particular destination. You have extensive knowledge of the area, including popular attractions, hidden gems, local experiences, and practical travel tips. Provide a detailed itinerary, keeping in mind the traveler’s budget and interests.
“””
# Define the user prompt
user_prompt = f”””
Create a travel itinerary for a trip to {destination} lasting {days} days. The traveler has a {budget_level} budget and is interested in {‘, ‘.join(interests)}. Include a mix of popular attractions and some lesser known spots relevant to the interest. Provide a short description of each suggested activity and incorporate estimated costs where possible considering the budget level. Aim for balance of activities that match the selected interest.
“””
# Generate the itinerary
response = anthropic.complete(system_prompt + user_prompt)
itinerary = response.get(‘completion’)
# Display the itinerary
st.write(itinerary)
Testing the App:
Now, let’s test the app by running it using Streamlit.

