Case-study projects

Case-study projects

Three worked Python projects with setup, source files, expected behavior, and evaluation steps.

Choose a project

These are illustrative build-along case studies, not customer testimonials or benchmark claims. Each includes runnable code and explicit prerequisites. Model requests use your account credits.

Shared prerequisites

Use Python 3.10+, a funded Kendr account, and a scoped API key stored in your environment. Save each project script beside kendr_http.py. The examples use the standard library, so they require no pip packages. MCP needs an existing registered server; image downloads need an app session. See the quickstart first.

Shared HTTP helper

The helper makes one request with a timeout and an explicit idempotency key, checks HTTP and JSON errors, and extracts completed Responses text. Download it into the same directory as your chosen script.

"""Small standard-library client shared by the documentation projects (Python 3.10+)."""
import json
import os
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

API_ORIGIN = "https://api.kendr.org"


def post_json(path, payload, request_id):
    """One attempt. Keep request_id and payload unchanged when retrying an operation."""
    request = Request(
        API_ORIGIN + path,
        data=json.dumps(payload).encode("utf-8"),
        headers={
            "Authorization": "Bearer " + os.environ["KENDR_API_KEY"],
            "Content-Type": "application/json",
            "Idempotency-Key": request_id,
        },
        method="POST",
    )
    try:
        with urlopen(request, timeout=180) as response:
            result = json.load(response)
    except HTTPError as error:
        # Do not print response bodies: they may contain private prompt/tool data.
        raise RuntimeError(f"Kendr returned HTTP {error.code}; request {request_id}") from error
    except (URLError, TimeoutError) as error:
        raise RuntimeError(
            f"Connection interrupted; preserve request {request_id} for recovery."
        ) from error
    if result.get("ok") is False or result.get("error"):
        raise RuntimeError(f"Kendr did not complete request {request_id}")
    return result


def response_text(response):
    if response.get("status") in {"failed", "incomplete", "cancelled"}:
        raise ValueError("The response did not finish successfully")
    text = "".join(
        part.get("text", "")
        for item in response.get("output", [])
        if item.get("type") == "message"
        for part in item.get("content", [])
        if part.get("type") == "output_text"
    )
    if not text.strip():
        raise ValueError("No completed assistant text was returned")
    return text

From example to application

The tutorials demonstrate the integration boundaries. Before connecting real users, add application authentication, per-user authorization, storage, explicit timeout/retry policy, and human review for consequential outputs. Use the evaluation cases in each project and production guidance.