Run a complete Python example
Install the HTTP client with python -m pip install requests. In your server environment, set JEV_API_KEY to an account API key and make sure the account holds decision credits. Set JEV_IDEMPOTENCY_KEY once for this logical request: generate a UUID with python -c "import uuid; print(uuid.uuid4())" and keep that value for retries. Neither value belongs in browser code or a public repository.
Save the example as classify.py and run python classify.py. The text and labels are defined, HTTP errors stop execution before parsing a success response, and the output prints the proposed classification and review flag. It does not route a ticket or modify another system. Use a new saved request key when you deliberately change the input; keep the old key and exact payload when a network outcome is unknown.
import json
import os
import requests
api_key = os.environ["JEV_API_KEY"].strip()
request_key = os.environ["JEV_IDEMPOTENCY_KEY"].strip()
if not api_key:
raise ValueError("JEV_API_KEY must not be empty")
if not 8 <= len(request_key) <= 100:
raise ValueError("JEV_IDEMPOTENCY_KEY must be 8-100 characters")
payload = {
"text": "I was charged twice for the same order.",
"instructions": "Choose the team responsible for this request.",
"labels": ["Billing", "Support", "Access"],
"threshold": 0.85,
}
response = requests.post(
"https://jevapi.pro/api/v1/decisions",
headers={
"Authorization": "Bearer " + api_key,
"Idempotency-Key": request_key,
},
json=payload,
timeout=(5, 30),
)
response.raise_for_status()
answer = response.json()
print(json.dumps({
"id": answer["id"],
"choice": answer["choice"],
"needsReview": answer["needsReview"],
}, ensure_ascii=False, indent=2))Read the answer as evidence, not as a verdict
A new decision answers 201 with id, choice, confidence, probabilities, needsReview, model and latencyMs, and an account request also returns the credits left. confidence is null when the model omits it, and needsReview is true in that case and whenever the reported confidence falls below your threshold.
probabilities is checked for domain and bounds only. Nothing promises that its values sum to one or that the largest one matches the returned label, so read choice instead of sorting a dictionary to guess the answer, and treat a label outside your list as a refusal rather than a fallback.
Process a file without duplicate charges
For a CSV, send rows sequentially and retain each logical request key alongside a stable source record ID, the exact payload and its outcome. Do not use the row number as identity: inserting a row in a later export changes the positions. A changed rule or changed input is a new logical request, not a retry.
A timeout, disconnected connection or generic gateway 502/503 does not prove that nothing was charged. Stop automatic routing and retry the same payload with the same key to recover a completed result. A 409 request_running keeps that key; an authoritative 409 request_failed confirms the recorded failure and allows a new key after fixing the cause. Do not replace the key merely because a proxy returned an error.
A 402 means insufficient credits. A 401 can mean a missing, revoked or expired-access API key; check account access before retrying. A 429 means a rate or allowance limit: respect Retry-After when present and use a bounded backoff, not an endless loop. This example intentionally sends once and raises errors so your job runner can decide what to retry. If you do not need a script, the batch workspace already preserves row states and exports results without including source text.
Batch classification and exports · Open the batch workspace · Error codes and recovery
Choose an API or a model you host
A scikit-learn or transformer model can be economical when labels are stable, you have suitable training data, and you can operate inference. It is not free per row: compute, maintenance, evaluation and human review still cost money. Compare measured total cost and latency on your own workload rather than assuming either option is always cheaper.
An API fits when you want to supply a task and labels without serving a model yourself. Its tradeoffs include network dependency, provider processing of submitted text and usage charges. A local model may better fit an offline or strict data-residency requirement. Neither option turns a confidence score into a guarantee.
Before automating, compare the same held-out examples, including ambiguous messages, against labels people reviewed. Start by recording suggestions. Route only the cases your evaluation supports, and keep needsReview results in an existing human queue.
