Skip to content

OpenAI: Images API (client.images.generate()) not instrumented #124

@braintrust-bot

Description

@braintrust-bot

Gap

The OpenAI Images API (client.images.generate(), client.images.edit(), client.images.create_variation()) is not instrumented. Calling any client.images.* method on a wrapped client falls through via NamedWrapper.__getattr__ (line 24 of oai.py) to the original unwrapped resource — the request succeeds but produces no Braintrust span.

The SDK explicitly wraps five resource namespaces — chat, beta, responses, embeddings, and moderations — but not images, despite it being one of the most widely used OpenAI API surfaces.

What is missing

  • client.images.generate() — text-to-image generation (DALL·E 3, gpt-image-1). Should create a span logging the prompt, model, size, quality, style, response URLs/b64, and revised prompt.
  • client.images.edit() — image editing with a text prompt. Same span data plus the source image reference.
  • client.images.create_variation() — image variations.

Token metrics do not apply to image generation, but cost, latency, model, and request/response metadata are all valuable for observability.

Braintrust docs status

not_found — the OpenAI integration page does not mention the Images API.

Upstream sources

Local files inspected

  • py/src/braintrust/oai.py:
    • OpenAIV1Wrapper.__init__ (lines 924–948) — wraps chat, beta, responses, embeddings, moderations only; images is absent
    • NamedWrapper.__getattr__ (line 24) — delegates unwrapped resources to the underlying client
  • py/src/braintrust/wrappers/test_openai.py — no tests reference images.generate or any images API method
  • Grep for images across oai.py: zero results related to the Images resource

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions