Skip to content

Jev

Text Generation • typesafe

View as MarkdownAgent setup
  • Third-party

Jev is TypeSafe's structured evaluation model. It evaluates one state against typed Noul, Choice, and Score questions and returns calibrated answers with probabilities and confidence.

Model Info
Context Window32,000 tokens
Terms and Licenselink
More informationlink
PricingView pricing in the Cloudflare dashboard

Usage

const response = await env.AI.run(
  'typesafe/jev',
  {
    state: 'Help! My payouts have been failing for 3 days.',
    questions: {
      is_urgent: {
        type: 'noul',
        instructions: 'Does this convey urgency?',
        criteria: { true: 'Explicitly time-sensitive', false: 'No urgency expressed' },
      },
      department: {
        type: 'choice',
        instructions: 'Which team should handle this?',
        criteria: {
          billing: 'Payments, invoicing, refunds',
          technical: 'Bugs, outages, integrations',
          sales: 'Pricing, upgrades, new accounts',
        },
      },
      frustration: {
        type: 'score',
        instructions: 'How frustrated is the customer?',
        criteria: ['Calm', 'Frustrated', 'Very angry'],
      },
    },
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "typesafe/jev",
  "input": {
    "state": "Help! My payouts have been failing for 3 days.",
    "questions": {
      "is_urgent": {
        "type": "noul",
        "instructions": "Does this convey urgency?",
        "criteria": {
          "true": "Explicitly time-sensitive",
          "false": "No urgency expressed"
        }
      },
      "department": {
        "type": "choice",
        "instructions": "Which team should handle this?",
        "criteria": {
          "billing": "Payments, invoicing, refunds",
          "technical": "Bugs, outages, integrations",
          "sales": "Pricing, upgrades, new accounts"
        }
      },
      "frustration": {
        "type": "score",
        "instructions": "How frustrated is the customer?",
        "criteria": [
          "Calm",
          "Frustrated",
          "Very angry"
        ]
      }
    }
  }
}'
{
  "model": "jev-1.13.0",
  "answers": {
    "is_urgent": {
      "type": "noul",
      "noul": 0.95
    },
    "department": {
      "type": "choice",
      "choice": "billing",
      "confidence": 0.8,
      "probabilities": {
        "billing": 0.87,
        "sales": 0,
        "technical": 0.13
      }
    },
    "frustration": {
      "type": "score",
      "score": 1.04,
      "confidence": 0.94,
      "legend": {
        "0": "Calm",
        "1": "Frustrated",
        "2": "Very angry"
      },
      "probabilities": {
        "0": 0,
        "1": 0.96,
        "2": 0.04
      }
    }
  },
  "usage": {
    "input_tokens": 426,
    "output_tokens": 73
  }
}

Examples

Structured refund review — Evaluate a refund request against a structured order and policy
const response = await env.AI.run(
  'typesafe/jev',
  {
    state: {
      ticket: {
        subject: 'Duplicate charge',
        message: 'I was charged twice for order A-104. Please refund the duplicate.',
      },
      order: {
        id: 'A-104',
        charges: [
          { amount_usd: 49, status: 'captured' },
          { amount_usd: 49, status: 'captured' },
        ],
      },
      refund_policy: 'Duplicate charges are eligible for a refund.',
    },
    questions: {
      refund_requested: { type: 'noul', instructions: 'Does `ticket.message` request a refund?' },
      policy_supports_refund: {
        type: 'noul',
        instructions:
          'Does `refund_policy` support the refund requested in `ticket.message`, given `order.charges`?',
      },
    },
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "typesafe/jev",
  "input": {
    "state": {
      "ticket": {
        "subject": "Duplicate charge",
        "message": "I was charged twice for order A-104. Please refund the duplicate."
      },
      "order": {
        "id": "A-104",
        "charges": [
          {
            "amount_usd": 49,
            "status": "captured"
          },
          {
            "amount_usd": 49,
            "status": "captured"
          }
        ]
      },
      "refund_policy": "Duplicate charges are eligible for a refund."
    },
    "questions": {
      "refund_requested": {
        "type": "noul",
        "instructions": "Does `ticket.message` request a refund?"
      },
      "policy_supports_refund": {
        "type": "noul",
        "instructions": "Does `refund_policy` support the refund requested in `ticket.message`, given `order.charges`?"
      }
    }
  }
}'
{
  "model": "jev-1.13.0",
  "answers": {
    "refund_requested": {
      "type": "noul",
      "noul": 0.99
    },
    "policy_supports_refund": {
      "type": "noul",
      "noul": 0.98
    }
  },
  "usage": {
    "input_tokens": 422,
    "output_tokens": 41
  }
}
Support department routing — Route a support request to the right department
const response = await env.AI.run(
  'typesafe/jev',
  {
    state: 'I cannot log in after changing my password, and the reset email never arrives.',
    questions: {
      department: {
        type: 'choice',
        instructions: 'Which team should handle this support request?',
        criteria: {
          account: 'Login, password, profile, or security issues',
          billing: 'Charges, invoices, refunds, or subscriptions',
          technical: 'Product bugs, outages, or integrations',
          other: 'Requests that do not fit the other departments',
        },
      },
    },
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "typesafe/jev",
  "input": {
    "state": "I cannot log in after changing my password, and the reset email never arrives.",
    "questions": {
      "department": {
        "type": "choice",
        "instructions": "Which team should handle this support request?",
        "criteria": {
          "account": "Login, password, profile, or security issues",
          "billing": "Charges, invoices, refunds, or subscriptions",
          "technical": "Product bugs, outages, or integrations",
          "other": "Requests that do not fit the other departments"
        }
      }
    }
  }
}'
{
  "model": "jev-1.13.0",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "account",
      "confidence": 1,
      "probabilities": {
        "technical": 0,
        "billing": 0,
        "account": 1,
        "other": 0
      }
    }
  },
  "usage": {
    "input_tokens": 380,
    "output_tokens": 45
  }
}
Account risk assessment — Score account risk and determine whether escalation is needed
const response = await env.AI.run(
  'typesafe/jev',
  {
    state: {
      account_age_days: 12,
      recent_events: [
        'Five failed login attempts',
        'Password reset requested from a new country',
        'Successful login from the usual device',
      ],
      account_verified: true,
    },
    questions: {
      risk_level: {
        type: 'score',
        instructions: 'How risky does this account activity appear?',
        criteria: [
          'Low risk: activity is consistent with the account history',
          'Moderate risk: some unusual activity needs monitoring',
          'High risk: multiple strong indicators of account compromise',
        ],
      },
      escalate: {
        type: 'noul',
        instructions: 'Should this account be escalated for manual security review?',
        criteria: {
          true: 'The activity warrants immediate human review',
          false: 'The activity can be handled with normal automated controls',
        },
      },
    },
  },
)
console.log(response)
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "model": "typesafe/jev",
  "input": {
    "state": {
      "account_age_days": 12,
      "recent_events": [
        "Five failed login attempts",
        "Password reset requested from a new country",
        "Successful login from the usual device"
      ],
      "account_verified": true
    },
    "questions": {
      "risk_level": {
        "type": "score",
        "instructions": "How risky does this account activity appear?",
        "criteria": [
          "Low risk: activity is consistent with the account history",
          "Moderate risk: some unusual activity needs monitoring",
          "High risk: multiple strong indicators of account compromise"
        ]
      },
      "escalate": {
        "type": "noul",
        "instructions": "Should this account be escalated for manual security review?",
        "criteria": {
          "true": "The activity warrants immediate human review",
          "false": "The activity can be handled with normal automated controls"
        }
      }
    }
  }
}'
{
  "model": "jev-1.13.0",
  "answers": {
    "risk_level": {
      "type": "score",
      "score": 1.84,
      "confidence": 0.77,
      "legend": {
        "0": "Low risk: activity is consistent with the account history",
        "1": "Moderate risk: some unusual activity needs monitoring",
        "2": "High risk: multiple strong indicators of account compromise"
      },
      "probabilities": {
        "0": 0,
        "1": 0.16,
        "2": 0.84
      }
    },
    "escalate": {
      "type": "noul",
      "noul": 0.81
    }
  },
  "usage": {
    "input_tokens": 421,
    "output_tokens": 36
  }
}

Parameters

model
stringminLength: 1

API Schemas (Raw)

Input
Output

Was this helpful?