Skip to content

Support OpenAI-compatible Batch API (/v1/batches and /v1/files) #1291

Description

@YaoZengzeng

What would you like to be added:

Add first-class support for an OpenAI-compatible Batch API to Kthena, so that users can submit, track, and manage large-scale offline/asynchronous inference jobs against models served by Kthena, in addition to the existing interactive (synchronous) serving path.

Rather than introducing a separate standalone service, this capability should be built into the kthena-router itself, extending the existing data-plane component with a batch-serving path alongside its interactive routing.

Concretely, this would include:

  • OpenAI-compatible endpoints with schema parity, served by the router:
    • /v1/files — upload/download/list/delete the JSONL input and output files used by batch jobs.
    • /v1/batches — create, retrieve, list, and cancel batch jobs, with real-time status/progress fields matching the OpenAI Batch object (status, request_counts, output_file_id, error_file_id, etc.).
  • Large-scale job processing — support many thousands of requests per job (e.g. tens of thousands), reading requests from an input file and writing results to an output file.
  • Asynchronous execution decoupled from interactive traffic — the router dispatches batch requests to Kthena-served backends (vLLM/SGLang/Triton) reusing its existing routing and load-balancing logic, in a way that minimizes interference with latency-sensitive interactive workloads, ideally with adaptive concurrency/flow control so batch throughput backs off when interactive traffic or backend pressure rises.
  • Router-integrated design — the batch API, job queue, and dispatch loop live inside the router process (or as an optional sub-module of it) rather than as separate deployables, so operators get batch support without deploying and scaling an additional component. It should be exposed through the existing router deployment and Helm charts, with liveness/readiness probes and Prometheus metrics.
  • Pluggable storage backends — for job/file metadata, the job queue, and file storage (e.g. object storage such as S3, plus a relational/queue backend), so operators can choose backends that fit their environment.
  • Job lifecycle management — cancellation during processing, fault tolerance/recovery if the router restarts, and garbage collection of expired jobs and files.

Kthena, being a Kubernetes-native LLM serving platform with a control plane and an intelligent router, is a natural place to offer this capability. Because the router already owns request classification, model-aware routing (KV-cache aware, model-load aware), and traffic control, embedding the batch path there lets batch dispatch directly reuse those mechanisms — e.g. grouping/ordering requests by model and system-prompt prefix to keep KV-cache hot, and sharing a single view of backend load between interactive and batch traffic.

Why is this needed:

  • Large offline/batch workloads are a first-class LLM use case — dataset inference, embedding generation for large corpora, model evaluation/testing, and offline analysis. These are asynchronous and throughput-oriented rather than latency-sensitive, and are awkward to run over a purely synchronous serving API.
  • OpenAI compatibility lowers adoption friction — many teams already build against the OpenAI /v1/batches and /v1/files API. Exposing the same schema lets them move batch workloads to Kthena without rewriting client code.
  • Better cluster utilization and cost efficiency — batch jobs can soak up spare capacity and be dispatched with adaptive concurrency control so they yield to interactive traffic, enabling differentiated SLOs and cost-optimized inference (batch vs. interactive) on shared infrastructure.
  • Completes the serving story with no extra moving parts — Kthena already provides production-grade interactive serving, autoscaling, and intelligent routing. Building batch support into the router lets a single component and deployment cover both interactive and batch inference, instead of requiring a separate system for offline jobs.

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions