Implementation

How to Use TypeSafe Jev on OpenRouter: Decisions API Guide

How to call TypeSafe Jev on OpenRouter using the /api/alpha/decisions endpoint, model identifier typesafe/jev-1.13, pricing, and Python/cURL examples.

TypeSafe Jev is available on OpenRouter under the model identifier typesafe/jev-1.13 (and alias typesafe/jev-latest). Because Jev evaluates structured state against typed questions rather than generating natural language text, it does not use OpenRouter's standard /v1/chat/completions endpoint. Instead, requests are submitted to OpenRouter’s Decisions API at POST https://openrouter.ai/api/alpha/decisions or called via openrouter.alpha.decisions.create() in OpenRouter’s official SDKs, billed at the identical $0.042 per million input tokens with unmetered output.

Why OpenRouter Uses the Decisions API for Jev

OpenRouter’s standard routing layer is optimized for autoregressive models that receive message arrays and return token streams. Jev breaks this assumption in two ways:

  1. Non-Autoregressive: Jev computes all outputs simultaneously in 70ms to 500ms (as reported by TypeSafe) rather than streaming tokens over seconds.
  2. Typed Primitives: It requires question schemas (choice, score, noul) and returns calibrated mathematical probabilities rather than markdown strings.

To accommodate this architecture, OpenRouter introduced the Alpha Decisions API (/api/alpha/decisions).

Python SDK Example

Using OpenRouter’s official Python SDK (openrouter), invoke Jev via the alpha.decisions module:

pip install openrouter
import os
from openrouter import OpenRouter

with OpenRouter(
    api_key=os.environ.get("OPENROUTER_API_KEY")
) as router:
    response = router.alpha.decisions.create(
        model="typesafe/jev-1.13",
        state={
            "customer_id": "cust_8820",
            "message": "My card was charged $49.00 twice on checkout. Please reverse the duplicate charge.",
            "account_age_days": 180
        },
        questions={
            "is_chargeback_risk": {
                "type": "noul",
                "instructions": "Is this customer expressing intent to file an external bank chargeback?",
                "criteria": {
                    "true": "Threatens bank dispute, fraud report, or legal action.",
                    "false": "Standard refund inquiry or friendly billing clarification."
                }
            },
            "routing_target": {
                "type": "choice",
                "instructions": "Determine the support department for this inquiry.",
                "criteria": {
                    "billing": "Invoices, double charges, payment processing errors.",
                    "support": "Product usage questions, bug reports.",
                    "legal": "Formal compliance demands, legal notices."
                }
            },
            "urgency": {
                "type": "score",
                "instructions": "Rate ticket urgency from standard to emergency.",
                "criteria": [
                    "Standard response SLA (24 hours)",
                    "Elevated attention required (4 hours)",
                    "Immediate escalation (15 minutes)"
                ]
            }
        }
    )

    print("Decision Response:")
    print(f"Chargeback Risk Probability: {response.answers['is_chargeback_risk'].noul:.1%}")
    print(f"Assigned Team: {response.answers['routing_target'].choice} (Confidence: {response.answers['routing_target'].confidence})")
    print(f"Urgency Score: {response.answers['urgency'].score}")

Direct HTTP / cURL Example

You can also call OpenRouter’s Decisions API directly using standard HTTP POST:

curl --request POST \
  --url https://openrouter.ai/api/alpha/decisions \
  --header "Authorization: Bearer $OPENROUTER_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "typesafe/jev-1.13",
    "state": {
      "query": "Upgrade enterprise subscription to 500 seats with SSO integration"
    },
    "questions": {
      "intent": {
        "type": "choice",
        "instructions": "Classify sales lead intent.",
        "options": ["enterprise_expansion", "support_request", "cancellation", "spam"]
      },
      "lead_score": {
        "type": "score",
        "instructions": "Evaluate enterprise deal potential.",
        "levels": ["low", "moderate", "high", "exceptional"]
      }
    }
  }'

OpenRouter vs. Direct TypeSafe API

FactorDirect TypeSafe API (api.typesafe.ai)OpenRouter (openrouter.ai)
Model Slugjev-latest / jev-1.13.0typesafe/jev-1.13
Token Price$0.042 / 1M input ($0.00 output rate)$0.042 / 1M input ($0.00 output rate)
Account AccessRequires TypeSafe waitlist invitationAvailable immediately with OpenRouter balance
BillingDedicated TypeSafe invoiceUnified OpenRouter credits across 200+ models
Latency OverheadDirect baseline (~100ms typical reported by TypeSafe)+15ms to +35ms routing proxy hop
Client SDKsOfficial @typesafe-ai/sdk, typesafe-sdkOfficial openrouter Python / TypeScript SDKs

Related Context

reference cost alternative