Jev 101
English ▾
API access/Access the API

Make your first call: HTTP, Python and JavaScript

Turn one redacted text into a typed answer and inspect usage.

Route used in this lesson

This lesson uses OpenRouter, which currently has a self-service path: sign up → add Credits → create OPENROUTER_API_KEY. If you chose Cloudflare or Vercel, follow the matching credentials and endpoint on the access routes page; changing only the model name is not enough.

Minimal request

Save this as request.json:

{
  "model": "typesafe/jev-1.13",
  "state": "My parcel has not arrived. Please check the delivery status.",
  "questions": {
    "asks_shipping": {
      "type": "noul",
      "instructions": "Does the customer ask about delivery or shipping?"
    }
  }
}

Set OPENROUTER_API_KEY, then call the dedicated Decisions API:

curl --fail-with-body https://openrouter.ai/api/alpha/decisions \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @request.json

Python

Install requests and save this as first_call.py:

python -m pip install requests
import json, os, requests

with open("request.json", encoding="utf-8") as file:
    payload = json.load(file)

response = requests.post(
    "https://openrouter.ai/api/alpha/decisions",
    headers={"Authorization": f"Bearer {os.environ['OPENROUTER_API_KEY']}"},
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(response.json())

JavaScript

Use Node.js 20 or newer. Never expose the key in browser code:

import { readFile } from "node:fs/promises";

const payload = JSON.parse(await readFile("request.json", "utf8"));
const response = await fetch("https://openrouter.ai/api/alpha/decisions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify(payload)
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
console.log(await response.json());

Acceptance check

The response should contain answers.asks_shipping, its answer type and a probability from 0 to 1. Record the actual model, usage and errors before adding retries, rate limits or business actions.

Sources and verification boundary

Reviewed September 19, 2026. Documentation-based guidance, not a live API or business-performance test.

OpenRouter · Jev 1.13 →
Reading progress stays in this browser