Primary AI microservice for the 1World TravelVerse project.
This service exposes a FastAPI-based backend that provides:
- Profile extraction – builds a structured travel profile from free-form multilingual text using Gemini.
- AI geocoding – resolves noisy, multilingual location text into normalized names, coordinates, metadata and source URLs.
The microservice focuses on:
- reliable structured JSON output,
- multilingual understanding,
- fault-tolerant processing of imperfect input,
- clean schemas for downstream systems.
travelverse-ai-api provides two core AI capabilities:
- Converts arbitrary multilingual text into a structured traveler profile.
- Extracts interests, constraints, preferences, budget signals, timing hints and contextual intent.
- Always returns schema-validated JSON regardless of input quality.
- Interprets noisy or partial human-written location queries in any language.
- Performs reasoning + web search to identify real places and addresses.
- Returns:
- normalized English names,
- coordinates,
- country code,
- source URLs used by the model,
- translated locale-specific notes.
- Handles specific locations, ambiguous cases, generic queries and precise addresses.
The service is a lightweight FastAPI-based microservice composed of three layers:
- Exposes
/api/profile/extract,/api/profile/geocode, and/api/health. - Uses Pydantic for strict JSON schema validation.
- Protects endpoints using the
X-Guard-Tokenheader. - Accepts fully multilingual input.
- Drives both profile extraction and geocoding.
- Performs multilingual understanding, reasoning and web search.
- Always produces deterministic, strictly validated JSON outputs.
- Handles ambiguity resolution and structured normalization.
- Controlled through
.envandsettings.toml. - Defines service settings, security rules and Gemini service-account credentials.
- Keeps the service environment-agnostic and portable.
Clone the source repository.
Install uv (Python package/venv manager):
curl -LsSf https://astral.sh/uv/install.sh | sh
uv --versionCreate a virtual environment and install dependencies:
uv syncThis creates .venv in the project root and installs dependencies from pyproject.toml and uv.lock.
Create a .env file:
APP_ROOT=$(pwd)
cat > .env <<EOF
APP_MODE=development
APP_ROOT="$APP_ROOT"
APP_DEPRECATIONS=false
TZ=UTC
EOFConfigure settings.toml:
- Copy prepared
settings.tomlinto the project root - Ensure
[service],[security], and[genai]sections exist - Configure the Gemini service account in
[genai]:
[genai]
service_account_file = "/path/to/genai-sa-key.json"Place genai-sa-key.json on the server.
Run the service:
./service.shCheck that it is running:
http://{host}:{port}/api/healthhttp://{host}:{port}/api/profile/extracthttp://{host}:{port}/api/profile/geocode
All endpoints are served under /api and protected by the X-Guard-Token header
(configured in [security] of settings.toml).
Simple health check.
Returns:
{ "status": "ok" }Builds a structured travel preference profile from free-form multilingual text using Gemini.
Always returns a stable JSON schema.
LLM-based geocoding that:
- processes noisy / partial / multilingual input,
- performs reasoning + web search,
- resolves the place into normalized English names,
- returns coordinates, metadata and locale-translated notes.
This repository is currently optimized for internal development within the TravelVerse project.
If extending the service:
- keep prompts and schemas under strict version control,
- validate all Gemini outputs with Pydantic models,
- preserve deterministic JSON structure,
- ensure new endpoints include lightweight integration tests,
- maintain multilingual robustness.
- Powered by Gemini 2.5 Flash with service-account authentication.
- All AI prompts are embedded inside the codebase for reproducibility.
- Geocoding uses reasoning + web search; responses may vary based on real-time search results.
- Enable verbose logs in
settings.tomland readapp/logs/service.logfor debugging.
Recommended environment:
- Python 3.11+
uvfor dependency and venv management- FastAPI + Uvicorn for serving