"""Example: run a one-shot task with the AIR SDK.

Usage::

    export AIR_API_KEY="air_k1_..."
    python examples/test_one_shot.py

By default this connects to http://localhost:8000.  Override with::

    export AIR_BASE_URL="https://your-backend.example.com"
"""

import os
import sys
from dotenv import load_dotenv
import air

load_dotenv()

API_KEY = os.environ.get("AIR_API_KEY")
BASE_URL = os.environ.get("AIR_BASE_URL", "http://localhost:8000")
print(f"BASE_URL: {BASE_URL}")

if not API_KEY:
    sys.exit("Set AIR_API_KEY first:  export AIR_API_KEY='air_k1_...'")

client = air.AIR(api_key=API_KEY, base_url=BASE_URL)

result = client.arxiv("See https://arxiv.org/abs/2301.12345 for details.")
if result["downloads_successful"]>0:
    print("Downloaded arxiv pdf at",result["downloaded_files"])
if result["downloads_failed"]>0:
    print("Some downloads failed:", result["failed_downloads"])

client.close()
