T TelemHQ

Track OpenAIOpenAIAn AI provider whose APIs and models are commonly used for text generation, coding, reasoning, embeddings, and agent workflows.View glossary entrySource: OpenAI token guide Jobs

Send a TelemHQ pingpingA request sent to TelemHQ after a job runs. A ping can be a simple heartbeat or include JSON payload data about what happened.View glossary entrySource: TelemHQ docs after each OpenAI pipelinepipelineA sequence of automated steps that moves data or work from one stage to another. AI pipelines often include retrieval, model calls, post-processing, and reporting.View glossary entrySource: GitHub Actions CI docs run with modelmodelThe AI system that processes input and returns output. For monitoring, the model name helps explain which tool or provider produced a run and how its token usage should be priced.View glossary entrySource: Anthropic model docs, token usagetokensThe pieces of text an AI model processes. Token counts are often used to measure usage and calculate model cost.View glossary entrySource: OpenAI token guide, latencylatencyHow long a request or job takes to respond. AI job latency helps teams spot slow model calls, overloaded workers, or expensive retries.View glossary entrySource: MDN glossary, output counts, costcostThe money associated with a run, often estimated from token usage and provider pricing. TelemHQ can store cost fields when your job sends them.View glossary entrySource: OpenAI token guide, and quality signals.

Recommended PayloadpayloadThe structured data sent with a request. In TelemHQ, payloads should contain safe operational metadata, not prompts, completions, secrets, customer data, or private paths.View glossary entrySource: MDN API glossary

OpenAI Responses include a usage object with input tokensinput tokensTokens sent into a model as input. Tracking them helps teams understand how much context each run consumed.View glossary entrySource: OpenAI token guide, output tokensoutput tokensTokens produced by a model as output. They are part of total usage and are often priced separately from input tokens.View glossary entrySource: OpenAI token guide, and total tokens. TelemHQ stores those fields alongside your job-specific metrics.

{
  "provider": "openai",
  "model": "gpt-5",
  "status": "success",
  "input_tokens": 8120,
  "output_tokens": 940,
  "total_tokens": 9060,
  "latency_ms": 1840,
  "cost_usd": 0.42,
  "items_processed": 128,
  "items_failed": 0,
  "eval_score": 0.91
}

Avoid sending prompts, completions, customer data, or retrieved documents unless you intentionally want them in your TelemHQ historyrun historyThe stored record of previous job runs. TelemHQ uses run history to show payloads, failures, timing, token totals, and trends over time.View glossary entrySource: TelemHQ docs.

Node.js

Install the SDKSDKA software development kit is a package of tools or libraries for building with a platform or API.View glossary entrySource: MDN API glossary and set TELEMHQ_PING_URL to your trackertrackerA monitored job, AI pipeline, worker, script, or automation in TelemHQ. Each tracker has its own ping URL and run history.View glossary entrySource: TelemHQ docs URL.

npm install openai
import OpenAI from "openai";

const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const model = process.env.OPENAI_MODEL || "gpt-5";
const startedAt = Date.now();

try {
  const response = await client.responses.create({
    model,
    input: "Summarize today's support tickets."
  });

  const usage = response.usage || {};

  await fetch(process.env.TELEMHQ_PING_URL, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      provider: "openai",
      model: response.model || model,
      status: "success",
      input_tokens: usage.input_tokens || 0,
      output_tokens: usage.output_tokens || 0,
      total_tokens: usage.total_tokens || 0,
      latency_ms: Date.now() - startedAt,
      items_processed: 1,
      items_failed: 0,
      eval_score: 0.92
    })
  });
} catch (error) {
  await fetch(process.env.TELEMHQ_PING_URL, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      provider: "openai",
      model,
      status: "error",
      latency_ms: Date.now() - startedAt,
      items_processed: 0,
      items_failed: 1,
      error: error instanceof Error ? error.message : "Unknown error"
    })
  });

  throw error;
}

Python

Use this pattern at the end of a cron jobcron jobA scheduled task that runs automatically, often on a server. TelemHQ tracks cron jobs by receiving a ping after each run.View glossary entrySource: AWS EventBridge Scheduler docs, batchbatchA group of records or tasks processed together. Batch jobs are often monitored by counting processed items, failed items, duration, and cost.View glossary entrySource: Anthropic API overview script, or queue workerworkerA background process that performs work outside the main request path, such as syncing data, generating reports, or running AI tasks.View glossary entrySource: GitHub Actions CI docs.

pip install openai requests
import os
import time
import requests
from openai import OpenAI

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
model = os.getenv("OPENAI_MODEL", "gpt-5")
started_at = time.time()

try:
    response = client.responses.create(
        model=model,
        input="Summarize today's support tickets.",
    )

    usage = getattr(response, "usage", None)
    input_tokens = getattr(usage, "input_tokens", 0) if usage else 0
    output_tokens = getattr(usage, "output_tokens", 0) if usage else 0

    requests.post(
        os.environ["TELEMHQ_PING_URL"],
        json={
            "provider": "openai",
            "model": getattr(response, "model", model),
            "status": "success",
            "input_tokens": input_tokens,
            "output_tokens": output_tokens,
            "total_tokens": getattr(usage, "total_tokens", input_tokens + output_tokens) if usage else 0,
            "latency_ms": round((time.time() - started_at) * 1000),
            "items_processed": 1,
            "items_failed": 0,
            "eval_score": 0.92,
        },
        timeout=10,
    )
except Exception as exc:
    requests.post(
        os.environ["TELEMHQ_PING_URL"],
        json={
            "provider": "openai",
            "model": model,
            "status": "error",
            "latency_ms": round((time.time() - started_at) * 1000),
            "items_processed": 0,
            "items_failed": 1,
            "error": str(exc),
        },
        timeout=10,
    )
    raise

Suggested AssertionsassertionA rule that checks payload data after a run. Assertions can flag a job as unhealthy even if the process technically completed.View glossary entrySource: TelemHQ docs

Add these checks on the tracker detail page to catch silent AIAISoftware that performs tasks normally associated with human judgment, language understanding, or pattern matching. In TelemHQ, AI usually means jobs that call a model, agent, or coding tool.View glossary entrySource: Google Cloud Generative AI glossary pipeline failures.

  • status = success
  • items_processed > 0
  • items_failed = 0
  • cost_usd <= your budget
  • eval_score >= your quality threshold

Official reference: OpenAI Responses API.