IONOS Agent Docs v1.0 just launched!⭐ Star us on GitHub
docsBackend GuideSetup

Backend Setup (FastAPI)

1. Navigate to backend

cd backend

2. Create a virtual environment and activate it

a) Windows (PowerShell)

python -m venv .venv
.\.venv\Scripts\Activate.ps1

b) macOS / Linux (bash/zsh)

python3 -m venv .venv
source .venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

4. Set environment variables

$env:IONOS_API_KEY = "<your_ionos_api_key>"
$env:TAVILY_API_KEY = "<your_tavily_api_key>"

Both API keys are required:

  • IONOS_API_KEY: For accessing IONOS AI Models Hub
  • TAVILY_API_KEY: For web search functionality (essential for the ReAct agent)

Tip: You can also put these in a .env file.

5. Run the server

uvicorn main:app --host 127.0.0.1 --port 8000 --reload

The 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!"}]}'