Skip to content

Vercel AI SDK generateImage not instrumented (wrapper and auto-instrumentation) #1626

@braintrust-bot

Description

@braintrust-bot

Summary

The Vercel AI SDK exports a stable generateImage() core function for generating images from text prompts, but neither the wrapper (wrapAISDK) nor the auto-instrumentation plugin instruments it. Calls to generateImage() produce no Braintrust spans. By contrast, the OpenAI Responses API's image_generation_call output type is already handled with special attachment conversion in this repo.

What is missing

  • Wrapper (js/src/wrappers/ai-sdk/ai-sdk.ts): wrapAISDK only wraps generateText, streamText, generateObject, streamObject, and Agent class methods. No handling of generateImage.
  • Auto-instrumentation config (js/src/auto-instrumentations/configs/ai-sdk.ts): Only defines configs for text/object generation and Agent variants. No config for generateImage.
  • Channels (js/src/instrumentation/plugins/ai-sdk-channels.ts): No channel definition for generateImage.
  • Plugin (js/src/instrumentation/plugins/ai-sdk-plugin.ts): No handler for image generation calls.
  • Vendor types (js/src/vendor-sdk-types/ai-sdk-common.ts): AISDKNamespaceBase does not include generateImage.

Upstream reference

  • AI SDK generateImage() reference: https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-image
  • Stable core function (not experimental) in AI SDK v6.
  • Returns { image, images, usage, warnings, responses } where each image is a GeneratedFile with base64/Uint8Array/Buffer data plus media type.
  • Supports parameters: model, prompt, n, size, aspectRatio, seed, maxRetries.

Braintrust docs status

The Braintrust tracing guide lists "Vercel AI SDK" as a supported integration but does not enumerate which AI SDK functions are covered. generateImage is not mentioned (not_found).

Precedent in this repo

OpenAI Responses API image generation output is already enriched — processImagesInOutput in js/src/instrumentation/plugins/openai-plugin.ts converts image_generation_call base64 results to Braintrust Attachment objects. A similar approach could be used for AI SDK generateImage output.

Local files inspected

  • js/src/wrappers/ai-sdk/ai-sdk.ts
  • js/src/auto-instrumentations/configs/ai-sdk.ts
  • js/src/instrumentation/plugins/ai-sdk-channels.ts
  • js/src/instrumentation/plugins/ai-sdk-plugin.ts
  • js/src/vendor-sdk-types/ai-sdk-common.ts
  • js/src/instrumentation/plugins/openai-plugin.ts (for processImagesInOutput precedent)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions