How it works 3 min read
How Plan4Me builds an itinerary.
An AI trip planner is not one large prompt. Plan4Me runs six steps. A language model picks the places, and code sets the order, the times and the arithmetic.
Tokyo · 23 stops
The short version.
- The model never invents a place. It picks from a numbered candidate list that the code builds first.
- Code sets the order, the start times, the travel legs and the cost. The model does not set them.
23
stops in the Tokyo plan
5
days, one area each
3
candidate sources merged
210
seconds for the whole run
The pipeline.
Plan4Me runs a generation as a fixed sequence of six steps, under one 210 second budget. A step that runs out of time falls back to a simpler result. The run itself does not stop.
- The brief model A fast model turns your city, dates, travellers and interests into a planning profile.
- Three candidate sources code A vector index, the Plan4Me database and Google Places return real places. The code merges them into one numbered list.
- The model picks model One model call per day chooses that day's stops from the list, by ID only.
- The code schedules code The code sets the order, a start time for every stop, the travel legs and the cost.
- The optimiser repairs code Code checks the pace, the opening hours and the budget, then drops or swaps a stop that does not fit.
- The page you are reading code The code saves the trip. The Tokyo plan on this site is one of these runs.
Where the places come from.
Step two asks three sources at once. The code merges the three answers by lower case name. No source outranks another.
up to 30
Vector index
One sentence about the trip retrieves similar places.
50 + 20
Plan4Me database
Places by category, plus restaurants and cafes.
every run
Google Places
Text search runs on each generation, not as a fallback.
How a place gets a score.
Every candidate gets one number.
- The rating supplies the base, divided by five.
- The review count adds up to 0.5 more on a log scale.
- Your first matched interest adds 0.8. Your second adds 0.4.
- A place with no rating gets 2.5 out of 5. An event gets 3.5.
- A place you ask for by name gets 100 points. That beats every other candidate.
The city becomes day areas.
The code clusters every candidate that has coordinates. A k-means variant with a fixed starting point gives the same clusters for the same input. A model then gives each day one area, its only geographic decision.
The model picks by ID.
Each candidate carries a short token: a1, a2, a3 and so on. The model returns tokens, not names. A token outside the list is rejected.
The code retries a failed day once. After that it picks the day by score. This is why every stop is a real place with real coordinates.
One job each.
The model
- Chooses the places.
- Writes the notes.
The code
- Sets the order.
- Sets the times.
- Adds the travel legs.
- Adds the cost.
Plan4Me never lets one do both jobs.
The checks that run in code.
Once the model has picked the stops, the rest of the day is arithmetic.
How a cost is estimated.
These figures drive the daily budget check inside Plan4Me. They are internal estimates for that check, not prices from the plan.
See the output.
The five day Tokyo plan this code produced.
23 stops across five days, with a start time for every stop. Free to read.
Read the Tokyo plan
