API Access

Single-Label Documentation

POST/v1/label

Classify content based on a single label criteria.

Base URL
https://api.zentropi.ai
Authentication
Authorization: Bearer your_api_key_here
Request Body
Field Type Required Description
content_text string Conditional The text content to be labeled. At least one of content_text or content_image or content_video is required. Text can be provided together with image or video for multimodal labeling.
content_image string Conditional Base64-encoded image data (data URL format). At least one of content_text, content_image, or content_video is required. Both can be provided together. 5MB max size. Subscriber Only
content_video string Conditional Base64-encoded video data (data URL format). At least one of content_text, content_image, or content_video is required. Can be combined with content_text. 25MB max size, 60s max duration. Subscriber Only
criteria_text string Conditional The labeling criteria to use directly. Required unless labeler_id or labeler_version_id is provided. Cannot be combined with either field.
labeler_id string Conditional The ID of the labeler to use. Uses its latest deployed version unless labeler_version_id is specified. Optional when a specific labeler_version_id is provided. Cannot be combined with criteria_text.
labeler_version_id string No The ID of a deployed labeler version to use. Use "latest" or omit this field to use the latest deployed version of a specified labeler_id. Cannot be combined with criteria_text.
model string No Model to use for evaluation:
  • cope-latest (default) - currently cope-b-a4b for text and cope-b-a4b-mm for images/video
  • cope-a-9b - 1st gen text model
  • cope-b-a4b - 2nd gen text model
  • cope-b-a4b-mm - 2nd gen multimodal model (subscriber-only)
Response
Field Type Description
label string The classification result ("0" or "1")
confidence float Confidence score for the classification (0.5 to 1.0)
compute_time float Processing time in seconds, including inference, network, and API overhead.
Example Response
{
  "label": "1",
  "confidence": 0.87,
  "compute_time": 0.324
}

Multi-Label Documentation

POST/v1/multilabel

Evaluate up to 26 binary labeling policies against the same text in one request. Returns an ordered array containing one result per policy. This endpoint currently supports text only.

Base URL
https://api.zentropi.ai
Authentication
Authorization: Bearer your_api_key_here
Request Body
FieldTypeRequiredDescription
content_textstringYes The shared text to evaluate against every policy. Must not be blank. This endpoint currently supports text only.
modelstringYes* A model supporting multi-label evaluation: cope-b-s1.
labelersarray of objectsYes Between 1 and 26 labelers to evaluate. Each entry supplies inline criteria or references a saved labeler. See the fields below.

* Explicitly select a supported model. Omitting model selects cope-latest, which currently does not support multi-label requests.

Fields Within Each Labeler Item
FieldTypeRequiredDescription
keystringNo An optional caller-defined result identifier, distinct from labeler_id, echoed in the corresponding result. Must not be blank and must be unique within the request.
criteria_textstringConditional The policy to evaluate directly. Required unless labeler_id or labeler_version_id is provided. Cannot be combined with either field.
labeler_idstringConditional The deployed labeler to use. Uses its latest deployed version unless labeler_version_id is specified. Optional when a specific version ID is provided.
labeler_version_idstringNo A specific deployed version ID. Use "latest" or omit this field to select the latest deployed version of a supplied labeler_id.
Additional Rules
  • Different items may use inline criteria or deployed labelers in the same request.
  • The caller must have permission to access every referenced labeler.
  • Put criteria fields inside each labeler item, not at the request’s top level.
  • Content and model are shared across all labelers; they cannot be overridden per labeler.
  • Invalid or inaccessible policies fail the whole request; the endpoint does not return partial successes.
Example Request
{
  "model": "cope-b-s1",
  "content_text": "The vase arrived cracked. Please refund my payment.",
  "labelers": [
    {
      "key": "refund",
      "criteria_text": "The customer requests a refund."
    },
    {
      "key": "damage",
      "criteria_text": "The customer reports a damaged product."
    }
  ]
}
Response

Returns a JSON array in the same order as labelers, including when only one labeler is requested.

FieldTypeDescription
keystring The caller-supplied result key. Omitted if no key was supplied.
labelstring The binary classification: "0" or "1".
confidencefloat Confidence in the returned classification (0.5 to 1.0).
compute_timefloat Processing time in seconds, including inference, network, and API overhead. The same value appears in each result; do not add these values together.
Example Response

Illustrative response showing the documented fields:

[
  {
    "key": "refund",
    "label": "1",
    "confidence": 0.97,
    "compute_time": 0.324
  },
  {
    "key": "damage",
    "label": "1",
    "confidence": 0.95,
    "compute_time": 0.324
  }
]

Status Codes

These status codes and retry guidelines apply to both endpoints.

  • 200 - Success
  • 400 - Bad Request (e.g., unsupported input)
  • 401 - Unauthorized (e.g., invalid API key)
  • 403 - Forbidden (e.g., insufficient access)
  • 404 - Not Found (e.g., no matching asset)
  • 413 - Payload Too Large
  • 422 - Validation Error (e.g., missing required fields)
  • 429 - Too Many Requests (e.g., rate limited; try later)
  • 500 - Internal Server Error
  • 502 - Bad Gateway (e.g., model output invalid)
  • 503 - Service Unavailable (e.g., model not reachable)
  • 529 - Service Overloaded (e.g., too much traffic; try later)
Retrying requests

For HTTP 429 and 5xx responses, retry with exponential backoff and jitter. Honor the Retry-After header when present, and limit the number of retries. Other 4xx responses generally require correcting the request or resolving an authentication or access issue before retrying.

Code Samples

Single-Label Calls

Python
import requests

ZAPI_KEY = "your_api_key_here"
ZAPI_URL = "https://api.zentropi.ai/v1/label"

content_text = "This is a funny joke"
criteria_text = "Label jokes"

response = requests.post(
    ZAPI_URL,
    headers={"Authorization": f"Bearer {ZAPI_KEY}"},
    json={
        "content_text": content_text,
        "criteria_text": criteria_text,
    }
)

result = response.json()
print(f"Label: {result['label']}")
print(f"Confidence: {result['confidence']}")

# Example output:
# Label: 1
# Confidence: 0.85

# For multimodal examples, see this notebook:
# https://colab.research.google.com/drive/1jfMkpaoX5lAKoGpqVUeyv_4haGn1BUX6
JavaScript
const ZAPI_KEY = "your_api_key_here";
const ZAPI_URL = "https://api.zentropi.ai/v1/label";

// Label content using Z-API
const labelContent = async () => {
  const response = await fetch(ZAPI_URL, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${ZAPI_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      content_text: "This is a funny joke",
      criteria_text: "Label jokes"
    })
  });

  const result = await response.json();
  console.log(`Label: ${result.label}`);
  console.log(`Confidence: ${result.confidence}`);
};

labelContent();

// Example output:
// Label: 1
// Confidence: 0.85

Multi-Label Calls

Python
import requests

ZAPI_KEY = "your_api_key_here"
ZAPI_URL = "https://api.zentropi.ai/v1/multilabel"

response = requests.post(
    ZAPI_URL,
    headers={"Authorization": f"Bearer {ZAPI_KEY}"},
    json={
        "model": "cope-b-s1",
        "content_text": "The vase arrived cracked. Please refund my payment.",
        "labelers": [
            {
                "key": "refund",
                "criteria_text": "The customer requests a refund.",
            },
            {
                "key": "damage",
                "criteria_text": "The customer reports a damaged product.",
            },
        ],
    },
    timeout=120,
)
response.raise_for_status()

# Results are in the same order as the requested labelers.
results = response.json()
for result in results:
    print(f"{result['key']}: {result['label']} (confidence: {result['confidence']})")

# Shared compute time; do not sum across results.
print(f"Compute time: {results[0]['compute_time']} seconds")
JavaScript
const ZAPI_KEY = "your_api_key_here";
const ZAPI_URL = "https://api.zentropi.ai/v1/multilabel";

const labelContent = async () => {
  const response = await fetch(ZAPI_URL, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${ZAPI_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "cope-b-s1",
      content_text: "The vase arrived cracked. Please refund my payment.",
      labelers: [
        {
          key: "refund",
          criteria_text: "The customer requests a refund."
        },
        {
          key: "damage",
          criteria_text: "The customer reports a damaged product."
        }
      ]
    })
  });
  if (!response.ok) {
    throw new Error(`HTTP ${response.status}: ${await response.text()}`);
  }

  // Results are in the same order as the requested labelers.
  const results = await response.json();
  for (const result of results) {
    console.log(`${result.key}: ${result.label} (confidence: ${result.confidence})`);
  }

  // Shared compute time; do not sum across results.
  console.log(`Compute time: ${results[0].compute_time} seconds`);
};

labelContent().catch(console.error);