# AUREA AI API — Python example.
#   AUREA_API_KEY=aurea_live_... python3 example.py
import os

from aurea_client import AureaClient

aurea = AureaClient(os.environ["AUREA_API_KEY"])

# 1) Chat (billed per token at the published tier rates)
chat = aurea.chat([{"role": "user", "content": "What is AUREA?"}], lang="en")
print(chat["choices"][0]["message"]["content"])
print("charged", chat["charged"], "credits, balance", chat["balance"])

# 2) Market snapshot (0.01 credits)
prices = aurea.prices()
for s in prices.get("symbols", []):
    if s.get("available"):
        print(s["symbol"], s["price_usdt"], "USDT",
              "(%s%% 24h)" % s["change_24h_pct"])

# 3) AI signals with the measured track record (0.02 credits)
signals = aurea.signals()
print("signal hit rate:", signals.get("stats", {}).get("hit_rate_pct"), "%")

# 4) Latest news (0.01 credits)
news = aurea.news(limit=3)
for item in news["items"]:
    print("-", item["title"], item["url"])

# 5) Knowledge base search (0.01 credits)
kb = aurea.kb("What is staking?", lang="en")
for r in kb["results"]:
    print("Q:", r["question"])
