Skip to content

Generated Model Examples

Using Custom Generated Model

This example demonstrates how to use a custom model generated through Flio.ai GPT. When a model is specified, the problem, objective, and solver parameters are automatically disabled.

import requests

# Configuration 
API_BASE_URL = "https://api.flio.ai"
OPTIMIZE_ENDPOINT = "/solver/optimize"
API_KEY = "YOUR-API-KEY"

payload = {
  "vehicles": [
    {
      "id": "vehicle_1",
      "start": [41.0082, 28.9784],
      "end": [41.0082, 28.9784],
      "constraints": {
        "profile": "car",
        "capacity": 50,
        "time_window": ["08:00:00", "18:00:00"],
        "max_distance": 100000,
        "max_travel_time": 36000,
        "max_tasks": 5,
        "per_km": 800,
        "per_hour": 3000,
        "fixed": 5000
      }
    },
    {
      "id": "vehicle_2",
      "start": [41.0082, 28.9784],
      "end": [41.0082, 28.9784],
      "constraints": {
        "profile": "truck",
        "capacity": 100,
        "time_window": ["08:00:00", "18:00:00"],
        "max_distance": 150000,
        "max_travel_time": 43200,
        "max_tasks": 8,
        "per_km": 1200,
        "per_hour": 4000,
        "fixed": 8000
      }
    }
  ],
  "jobs": [
    {
      "id": "job_1",
      "amount": 20,
      "start": {
        "id": "warehouse",
        "coordinate": [41.0082, 28.9784],
        "setup": 300,
        "service": 600,
        "time_window": ["08:00:00", "18:00:00"]
      },
      "end": {
        "id": "customer_1",
        "coordinate": [41.0122, 28.9820],
        "setup": 120,
        "service": 480,
        "time_window": ["09:00:00", "12:00:00"]
      },
      "priority": 80
    },
    {
      "id": "job_2",
      "amount": 15,
      "start": {
        "id": "warehouse",
        "coordinate": [41.0082, 28.9784],
        "setup": 300,
        "service": 600,
        "time_window": ["08:00:00", "18:00:00"]
      },
      "end": {
        "id": "customer_2",
        "coordinate": [41.0050, 28.9750],
        "setup": 180,
        "service": 360,
        "time_window": ["10:00:00", "13:00:00"]
      },
      "priority": 60
    },
    {
      "id": "job_3",
      "amount": 30,
      "start": {
        "id": "warehouse",
        "coordinate": [41.0082, 28.9784],
        "setup": 300,
        "service": 600,
        "time_window": ["08:00:00", "18:00:00"]
      },
      "end": {
        "id": "customer_3",
        "coordinate": [41.0150, 28.9850],
        "setup": 240,
        "service": 720,
        "time_window": ["14:00:00", "17:00:00"]
      },
      "priority": 90
    }
  ],
  "options": {
    "model": "model-2025-08-08-v2",
    "map": "geographic",
    "timeout": 600
  }
}

url = f"{API_BASE_URL}{OPTIMIZE_ENDPOINT}?api_key={API_KEY}"
print(f"\nSending request with custom model: {url}")
response = requests.post(url, json=payload)
print(f"Response Status: {response.status_code}")

if response.status_code == 200:
    response_data = response.json()
    print(f"Response: {response_data}")

    # Print summary
    if "summary" in response_data:
        summary = response_data["summary"]
        print(f"\n=== CUSTOM MODEL SUMMARY ===")
        print(f"Total Distance: {summary.get('distance', 'N/A')} meters")
        print(f"Total Duration: {summary.get('duration', 'N/A')} seconds")
        print(f"Total Cost: {summary.get('cost', 'N/A')}")
        print(f"Unassigned Jobs: {summary.get('unassigned', 'N/A')}")

        # Note: Problem, objective, and solver are determined by the model
        print(f"\nNote: Using custom model 'model-2025-08-08-v2'")
        print(f"Problem type, objective, and solver are automatically set by the model")
else:
    print(f"Error: {response.status_code}")
    print(f"Response: {response.text}")

Key Differences When Using Generated Models

When you specify a model in the options:

  1. Automatic Configuration: The problem, objective, and solver parameters are automatically disabled and set by the model
  2. Model-Specific Logic: The model contains pre-trained logic for specific use cases and constraints
  3. Simplified Options: You only need to specify map, timeout, and other non-conflicting options
  4. Consistent Results: Models provide consistent optimization behavior for similar problem types

Available Models

You can access available models through: - Flio.ai GPT - Generate custom models for your specific use case - API documentation for pre-built models - Contact support for enterprise model options