Skip to main content

Environment Variables

Haggle uses environment variables for configuration. Create a config.py file in the project root or use .env files.
The config.py file is gitignored for security. You’ll need to create it manually with your credentials.

Backend Configuration

Creating config.py

Create a config.py file in the root directory:
config.py
"""Configuration for Haggle Service Marketplace."""
import os
from dotenv import load_dotenv

load_dotenv()

# xAI API Configuration
XAI_API_KEY = os.getenv("XAI_API_KEY", "your-xai-api-key-here")

# Supabase Configuration
SUPABASE_URL = os.getenv("SUPABASE_URL", "https://your-project.supabase.co")
SUPABASE_KEY = os.getenv("SUPABASE_KEY", "your-supabase-anon-key")

# Provider Search Configuration
MAX_PROVIDERS = int(os.getenv("MAX_PROVIDERS", "5"))

# Optional: Backend Service URL (for voice calling feature)
CALL_BACKEND_URL = os.getenv("CALL_BACKEND_URL", "http://localhost:6000")

Alternative: Using .env File

You can also create a .env file in the project root:
.env
# xAI API Key (required for Grok LLM)
XAI_API_KEY=your-xai-api-key-here

# Supabase Configuration (required)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-supabase-anon-key

# Optional: Maximum providers to return
MAX_PROVIDERS=5

# Optional: Call backend service URL
CALL_BACKEND_URL=http://localhost:6000
Never commit .env or config.py files to version control. Both are included in .gitignore by default.

Required API Keys

1

Get xAI API Key

Haggle uses Grok LLM for task inference and question generation.
  1. Visit x.ai and sign up for an account
  2. Navigate to the API section
  3. Generate a new API key
  4. Copy the key to your config.py or .env file
If no XAI_API_KEY is provided, Haggle will use fallback logic (rule-based task inference and default questions).
2

Get Supabase Credentials

Supabase provides your PostgreSQL database.
  1. Go to your Supabase Dashboard
  2. Select your project
  3. Navigate to SettingsAPI
  4. Copy the following:
    • Project URLSUPABASE_URL
    • anon public key → SUPABASE_KEY
Use the anon key for development. For production, consider using the service_role key with proper security measures.
3

Optional: Twilio Configuration (Voice Calling)

For the voice calling feature (backend/app.py), additional environment variables are needed:
.env
# Twilio Configuration
TWILIO_ACCOUNT_SID=your-twilio-account-sid
TWILIO_AUTH_TOKEN=your-twilio-auth-token
TWILIO_PHONE_NUMBER=+1234567890

# Domain for TwiML callbacks
DOMAIN=your-domain.com
Voice calling is an advanced feature requiring Twilio setup and a public domain for webhooks.

Configuration Reference

Core Settings

XAI_API_KEY
string
required
API key for xAI’s Grok LLM. Used for:
  • Task inference from user queries
  • Generating clarifying questions
  • Formatting problem statements
  • Extracting negotiated prices from call transcripts
Fallback: If not provided, uses rule-based logic
SUPABASE_URL
string
required
Your Supabase project URL (format: https://[project-id].supabase.co)Example: https://podtjfttutrybvotsduh.supabase.co
SUPABASE_KEY
string
required
Supabase anon/public API key for database operationsLocation: Dashboard → Settings → API → anon public

Optional Settings

MAX_PROVIDERS
integer
default:"5"
Maximum number of service providers to return from searchRange: 1-20 recommended
CALL_BACKEND_URL
string
default:"http://localhost:6000"
URL of the voice calling backend serviceUsed by: /api/start-calls/{job_id} endpoint in main.py:381

Voice Calling Configuration

TWILIO_ACCOUNT_SID
string
Twilio account identifier for voice calling
TWILIO_AUTH_TOKEN
string
Twilio authentication token
TWILIO_PHONE_NUMBER
string
Your Twilio phone number (E.164 format: +1234567890)
DOMAIN
string
Public domain for TwiML webhooks (required for voice calling)Example: your-app.ngrok.io or api.yourdomain.com

Database Schema

The providers table stores service provider information:
ColumnTypeDescription
idBIGSERIALPrimary key
service_providerTEXTProvider name (NOT NULL)
phone_numberTEXTContact phone
context_answersTEXTFormatted Q&A paragraph
house_addressTEXTFull customer address
zip_codeTEXTZIP code for location
max_priceNUMERIC(10,2)Customer’s budget
job_idTEXTAssociated job ID (NOT NULL)
minimum_quoteNUMERIC(10,2)Initial quote
problemTEXTProblem statement
negotiated_priceNUMERIC(10,2)Final agreed price
call_statusTEXTStatus: pending/in_progress/completed/failed
call_transcriptTEXTFull call transcript
created_atTIMESTAMPTZCreation timestamp

Verifying Configuration

Test your configuration with the CLI demo:
python cli.py --demo
Successful output indicates:
  • ✅ Supabase connection established
  • ✅ Grok LLM API working (or fallback active)
  • ✅ Database schema correct
You should see output like:
✅ Database initialized
🧠 STEP 2: Analyzing your request...
✓ Task identified: plumber
✓ Generated questions:
...
✓ Found 5 providers!
✓ Saved 5 providers to Supabase

Next Steps

Running Locally

Start the development servers

API Reference

Explore the API endpoints

Build docs developers (and LLMs) love