Skip to content

[bot] OpenAI Batch instrumentation silently drops /v1/embeddings batch requests #2425

Description

@braintrust-bot

Summary

This repo's OpenAI Batch API instrumentation (js/src/instrumentation/plugins/openai-batch-instrumentation.ts) creates spans for batch jobs submitted against /v1/chat/completions and /v1/responses, but the OpenAI Batch API officially supports six additional endpoints — including /v1/embeddings, a core embeddings execution surface that is explicitly in-scope for this repo's instrumentation (every other embeddings-capable provider wrapper here — OpenAI's own synchronous embeddings.create, Cohere, Mistral, Groq, HuggingFace, Voyage AI, AI SDK embed/embedMany — instruments embeddings calls). Batch embeddings jobs currently get zero tracing: no task span, no child spans, nothing.

What's missing

In js/src/instrumentation/plugins/openai-batch-instrumentation.ts:

  • SUPPORTED_ENDPOINTS (line 29) is hardcoded to new Set(["/v1/chat/completions", "/v1/responses"]).
  • readBatchInputs (line 333) rejects any JSONL record whose url isn't in that set — for a /v1/embeddings batch file, every record fails SUPPORTED_ENDPOINTS.has(url) (line 349) and is pushed onto issues as "OpenAI Batch input contains an invalid record" (line 353).
  • Because every record is rejected, endpoint is never set, so readBatchInputs also reports "OpenAI Batch input contains no supported records" (line 370).
  • interceptOpenAIFilesCreateTraced (line 399) and completeBatch (line 646) both bail out silently whenever inputData.issues.length > 0 (lines 416, 616), so an embeddings batch job produces no task span and no per-request child spans at all — not even a degraded/partial one.
  • extractOpenAIBatchInput in js/src/instrumentation/plugins/openai-span-data.ts (line 36-46) only branches on endpoint === "/v1/chat/completions" vs. everything else defaulting to params.input (the Responses API input shape) — it has no embeddings-specific extraction (e.g. minimizing the input the way extractOpenAIChatInput/existing sync embeddings paths do), so even if the endpoint filter were relaxed, embeddings batch requests would need their own extraction branch.

This means a customer submitting a client.batches.create({ endpoint: "/v1/embeddings", ... }) job — a fully supported, documented OpenAI API call — gets no trace of that batch job in Braintrust whatsoever, while the same customer's synchronous embeddings.create calls are traced.

Note: OpenAI's Batch API also supports /v1/completions, /v1/moderations, /v1/images/generations, /v1/images/edits, and /v1/videos, which are not generative/embeddings execution gaps of the same kind (image/video generation batch coverage would need to be assessed against this repo's existing image/video generation instrumentation separately) — this issue is scoped specifically to the /v1/embeddings batch endpoint, which is a clean, additive embeddings-execution gap in an otherwise-instrumented lifecycle.

Braintrust docs status

not_found. https://www.braintrust.dev/docs/providers/openai does not mention the Batch API, /v1/batches, or batch job tracing anywhere (TypeScript, Python, Ruby, Go, Java, or .NET sections). It documents only synchronous embeddings.create tracing ("output records the embedding length, not the raw vector"). No Braintrust docs page describes batch-endpoint coverage at all, so there's no documented claim to reconcile against — the instrumentation itself is the only source of truth, and it explicitly excludes /v1/embeddings.

Upstream sources

  • https://developers.openai.com/api/docs/guides/batch — lists the exact supported endpoint values: /v1/responses, /v1/chat/completions, /v1/embeddings, /v1/completions, /v1/moderations, /v1/images/generations, /v1/images/edits, /v1/videos. Also notes /v1/embeddings batches are capped at 50,000 embedding inputs per batch.
  • https://developers.openai.com/api/reference/resources/batches/methods/create — the create endpoint reference; the endpoint parameter description: "The endpoint to be used for all requests in the batch. Currently /v1/responses, /v1/chat/completions, /v1/embeddings, /v1/completions, /v1/moderations, /v1/images/generations, /v1/images/edits, and /v1/videos are supported."

Braintrust docs sources checked

Local repo files inspected

  • js/src/instrumentation/plugins/openai-batch-instrumentation.tsSUPPORTED_ENDPOINTS set (line 29), readBatchInputs validation (lines 333-373), interceptOpenAIFilesCreateTraced (line 399), completeBatch (line 646)
  • js/src/instrumentation/plugins/openai-span-data.tsextractOpenAIBatchInput (lines 36-46), contrasted with extractOpenAIChatInput/embeddings-minimization patterns used elsewhere
  • js/src/instrumentation/plugins/openai-batch-instrumentation.test.ts — existing test coverage only exercises /v1/chat/completions and /v1/responses batch scenarios
  • js/src/instrumentation/plugins/openai-channels.tsbatchesRetrieveTraced / batchesCompleteTrace channel definitions (no endpoint-specific typing)
  • js/src/openai-batch-types.ts — shared batch types referenced by the plugin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions