Backend Setup (FastAPI)
1. Navigate to backend
cd backend2. Create a virtual environment and activate it
a) Windows (PowerShell)
python -m venv .venv
.\.venv\Scripts\Activate.ps1b) macOS / Linux (bash/zsh)
python3 -m venv .venv
source .venv/bin/activate3. Install dependencies
pip install -r requirements.txt4. Set environment variables
Recommended: Create a .env file in the backend folder:
IONOS_API_KEY=your_ionos_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
# Optional: IONOS Studio fine-tuned models
STUDIO_API_KEY=your_studio_api_key_here
STUDIO_ORG_ID=your_studio_org_id_here
STUDIO_BASE=https://studio.ionos.de/api/v1
# Fine-tuned model UUIDs
STUDIO_MODEL_QWEN_GDPR=model_uuid_here
STUDIO_MODEL_GRANITE_GDPR=model_uuid_here
STUDIO_QWEN3_SHAREGPT=model_uuid_hereAlternative (shell environment variables):
Windows PowerShell:
$env:IONOS_API_KEY = "<your_ionos_api_key>"
$env:TAVILY_API_KEY = "<your_tavily_api_key>"macOS/Linux:
export IONOS_API_KEY="<your_ionos_api_key>"
export TAVILY_API_KEY="<your_tavily_api_key>"Required:
- IONOS_API_KEY: For accessing IONOS AI Models Hub (inference models)
- TAVILY_API_KEY: For web search functionality (essential for the ReAct agent)
Optional (for IONOS Studio fine-tuned models):
- STUDIO_API_KEY: API key for IONOS AI Model Studio
- STUDIO_ORG_ID: Your IONOS Studio organization ID (get from https://studio.ionos.de/platform/org/YOUR_ORG_ID/settings)
- STUDIO_BASE: Base URL for Studio API (defaults to
https://studio.ionos.de/api/v1) - STUDIO_MODEL_*: UUIDs of your fine-tuned models
5. Run the server
uvicorn main:app --host 127.0.0.1 --port 8000 --reloadThe API will be available at http://localhost:8000.
6. Test the chat endpoint
Run these from another terminal:
a) Windows (PowerShell)
Invoke-RestMethod `
-Uri "http://127.0.0.1:8000/" `
-Method Post `
-Headers @{ "x-model-id" = "mistralai/Mistral-Small-24B-Instruct" } `
-Body (@{ messages = @(@{ type = "human"; content = "Hello!" }) } | ConvertTo-Json -Depth 3) `
-ContentType "application/json"b) macOS / Linux (bash/zsh)
curl -s -X POST "http://127.0.0.1:8000/" \
-H "x-model-id: mistralai/Mistral-Small-24B-Instruct" \
-H "Content-Type: application/json" \
-d '{"messages":[{"type":"human","content":"Hello!"}]}'