Skip to content

[BOT ISSUE] OpenAI Images API not instrumented (openai + ruby-openai gems) #147

@braintrust-bot

Description

@braintrust-bot

Summary

The OpenAI Images API (client.images.generate) is available in both the official openai gem and the ruby-openai gem, but is not instrumented by this SDK. Image generation (DALL-E, gpt-image-1) is a stable generative AI API that creates images from text prompts. This is the same class of gap as the already-filed audio API issue (#146), and is distinct from the RubyLLM paint() gap (#136) which covers a different library.

What is missing

Official openai gem

Three resource methods under OpenAI::Resources::Images:

  • client.images.generate(...) — Text-to-image generation using DALL-E 3 or gpt-image-1. Accepts prompt, model, size, quality, style, n, response_format, background, output_format, output_compression, and more. Returns typed OpenAI::Models::ImagesResponse.
  • client.images.edit(...) — Image editing with text prompts. Accepts image file + prompt + mask.
  • client.images.create_variation(...) — Image variations from an existing image.

The official SDK also has streaming variants (generate_stream_raw, edit_stream_raw).

ruby-openai gem

Equivalent methods with hash-based parameters:

  • client.images.generate(parameters: { prompt:, model:, size:, quality:, ... })
  • client.images.edit(parameters: { ... })
  • client.images.variations(parameters: { ... })

Documented in the README with DALL-E 2 and DALL-E 3 examples.

Expected instrumentation

A new ImagesPatcher (following the existing ModerationsPatcher pattern) for each gem:

Image generation spans should capture:

  • Input: the text prompt
  • Metadata: model (e.g., dall-e-3, gpt-image-1), size, quality, style, n, response_format, provider, endpoint
  • Output: image URL(s) or metadata (not the binary/base64 image data itself)
  • Metrics: revised_prompt (when the model modifies the original prompt)

Braintrust docs status

not_found — Braintrust docs at https://www.braintrust.dev/docs/guides/tracing and the integrations pages do not mention image generation instrumentation. All examples focus on chat completions, embeddings, and audio.

Upstream sources

Local repo files inspected

  • lib/braintrust/contrib/openai/patcher.rb — defines ChatPatcher, ResponsesPatcher, ModerationsPatcher but no ImagesPatcher
  • lib/braintrust/contrib/openai/instrumentation/ — contains chat.rb, responses.rb, moderations.rb but no images.rb
  • lib/braintrust/contrib/ruby_openai/patcher.rb — defines ChatPatcher, ResponsesPatcher, ModerationsPatcher but no ImagesPatcher
  • lib/braintrust/contrib/ruby_openai/instrumentation/ — contains chat.rb, responses.rb, moderations.rb but no images.rb
  • Grep for images, dall, ImagesPatcher across lib/braintrust/ returns zero relevant matches

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions