Make your first request
Send input and a JSON Schema to get a structured answer. This example classifies a message into a department and identifies whether it reports a duplicate charge. It needs no registration, state or policy.
1. Connect
The API address is https://api.blatent.ai. Find your API key in the Blatent console, then set it in your terminal:
export BLATENT_API_KEY='YOUR_SERVICE_KEY'
The clients below send it as a Bearer token:
Authorization: Bearer YOUR_SERVICE_KEY
Keep the key in your server environment or secret manager, separate from the input, schema and state. Missing or invalid keys return 401.
For Python, use Python 3.10+ and install HTTPX:
python -m pip install "httpx>=0.28,<1"
For TypeScript, use Node.js 24+; the example uses built-in fetch. The cURL version needs curl and jq. Choose your language in the request tabs below.
2. Define the answer
Save triage.schema.json beside your client script. The schema gives the model two decisions: a category from enum and a boolean. Each description explains how to interpret the input. required keeps both fields present; additionalProperties: false prevents extra fields.
{
"type": "object",
"properties": {
"department": {
"type": "string",
"enum": ["billing", "technical", "other"],
"description": "Route charges, invoices and refunds to billing. Route broken product behavior to technical. Use other for anything else."
},
"duplicate": {
"type": "boolean",
"description": "True only when the message explicitly reports being charged more than once for the same purchase."
}
},
"required": ["department", "duplicate"],
"additionalProperties": false
}
3. Send a request
The client loads the schema unchanged and sends it with the message to /v1/resolve.
- Python
- TypeScript
- cURL
import json
import os
from pathlib import Path
import httpx
request = {
"input": "The invoice was charged twice. Can you help me get the duplicate charge refunded?",
"schema": json.loads(Path("triage.schema.json").read_text(encoding="utf-8")),
}
with httpx.Client(
base_url="https://api.blatent.ai",
headers={"Authorization": f"Bearer {os.environ['BLATENT_API_KEY']}"},
timeout=195,
) as client:
response = client.post("/v1/resolve", json=request)
response.raise_for_status()
print(json.dumps(response.json()["output"]))
import { readFileSync } from "node:fs";
const request = {
"input": "The invoice was charged twice. Can you help me get the duplicate charge refunded?",
"schema": JSON.parse(readFileSync("triage.schema.json", "utf8")),
};
const response = await fetch(
"https://api.blatent.ai" + "/v1/resolve",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.BLATENT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(request),
signal: AbortSignal.timeout(195_000),
},
);
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(JSON.stringify((await response.json()).output));
set -eu
body=$(jq -n --argjson body '{"input":"The invoice was charged twice. Can you help me get the duplicate charge refunded?"}' \
--slurpfile f0 'triage.schema.json' \
'$body | setpath(["schema"]; $f0[0])')
curl --fail-with-body --silent --show-error \
"https://api.blatent.ai/v1/resolve" \
-H "Authorization: Bearer $BLATENT_API_KEY" \
-H 'Content-Type: application/json' \
--data-binary "$body"
Save the client beside the schema, then run python classify.py, node classify.ts or bash classify.sh.
Read the result
Illustrative value of output:
{"department":"billing","duplicate":true}
Python and TypeScript print this value. cURL prints the complete response containing output. A successful answer uses the permitted fields and values; whether it understood the message correctly is a separate evaluation.
Small classifications are an efficient starting point: Struct supplies the fixed JSON structure and only asks the model to make the choices. No model field is needed.
To adapt this example, change the fields, choices and descriptions to match the answer your application needs. See output types, descriptions or schema registration.