跳到正文
Jev

Jev Python

Use requests (or httpx) with a jv_live_ key. There is no official pip package required — it is a plain HTTPS JSON API.

Python
import os
import requests

API = "https://jevtypesafe.org/api/v1/decide"

def decide(state: str) -> dict:
    r = requests.post(
        API,
        headers={
            "Authorization": f"Bearer {os.environ['JEV_API_KEY']}",  # jv_live_...
            "Content-Type": "application/json",
        },
        json={
            "state": state,
            "questions": {
                "topic": {
                    "type": "choice",
                    "instructions": "Route this message",
                    "criteria": {
                        "billing": "payments and refunds",
                        "bug": "product broken",
                        "account": "login or access",
                    },
                },
                "urgency": {
                    "type": "score",
                    "instructions": "How urgent?",
                    "criteria": ["low", "medium", "high", "critical"],
                },
                "escalate": {
                    "type": "noul",
                    "instructions": "Should a human take this now?",
                },
            },
        },
        timeout=30,
    )
    r.raise_for_status()
    return r.json()

if __name__ == "__main__":
    print(decide("I've been waiting five days for my refund."))