debug-batch-api

Diagnose Batch API production issues using Datadog logs, metrics, and GCS artifacts.

7|12|Updated Mar 26, 2026
One-click install
npx skills add https://github.com/OpenRouterTeam/docs --skill debug-batch-api-openrouterteam
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: debug-batch-api
Source: https://github.com/OpenRouterTeam/docs/tree/main/.agents/skills/debug-batch-api
Command: npx skills add https://github.com/OpenRouterTeam/docs --skill debug-batch-api-openrouterteam

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When a Batch API job is stuck, results are payment-blocked, usage is missing, or submission fails, engineers need a systematic way to trace the job through ingress, acceptance, submission, provider polling, finalization, billing, and results serving instead of guessing across scattered logs. ## Core Features & Use Cases - Lifecycle Tracing: Reconstructs an evidence-backed timeline for any batch job using Datadog log queries keyed by job ID, entity ID, trace ID, or symptom. - Symptom Decision Table: Maps symptoms like "batch stuck", "results 402", or "usage missing" to the correct lifecycle stage, queries, and likely causes. - GCS Artifact Inspection: Compares raw provider responses against materialized results in Google Cloud Storage to pinpoint parse and render failures. - Use Case: A customer reports their batch finished but results return HTTP 402. Use this Skill to query the payment-gate events, determine whether settlement is pending or explicitly blocked, and produce a root-cause report with a shareable Log Explorer URL. ## Quick Start Ask the AI to investigate why batch job batch-1785263765-XPvEnZuifmN37sHaJ9pm is stuck and produce a root-cause timeline.

Frequently Asked Questions about debug-batch-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug a stuck Batch API job in production?▼

Start with the job ID query across all batch-api services, then check sweep and finalize events such as sweep.poll_failed and finalize_one.finalize_failed. The symptom decision table maps "batch stuck" to provider poll failures, Pub/Sub retries, or missing provider job IDs.

Why are my batch results returning HTTP 402?▼

A 402 means the settlement outcome is explicitly payment_required, typically a failed or insufficient-balance charge. Query batch_api.get_batch.results_payment_blocked with the job or entity ID; a null settlement is a metadata-only 200 pending state, not a provider failure.

How do I find Batch API logs in Datadog?▼

Query service:batch-api* with the job ID under @data.jsonPayload.extra.job_id, since each Cloud Run worker role logs under its own service. Cloudflare ingress logs use source:cloudflare @script_name:batch-api instead.

Why is usage missing from my completed batch job?▼

Check emit_generations.done and emit_generation.missing_usage events for the job. Missing or malformed provider usage triggers fallback estimation, so inspect the estimated, unaccounted, and is_usage_complete fields rather than treating estimates as exact usage.

Can I compare raw provider output with served batch results?▼

Yes. Pull output/raw_response and output/results from the GCS bucket customer-data-batch-api-prod under the billable entity and job ID path. A field present only in the raw response was dropped by the parse/render transform.

What are the limitations of Datadog log retention for batch debugging?▼

Datadog retains logs for 14 days, so investigations older than that window cannot rely on log queries. GCS batch artifacts follow a separate 30-day retention lifecycle rule.