Skip to content

feat(openai): trace svg image output, svg_usage, and new 3.46 params - #1089

Open
Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit into
mainfrom
abhi/openai-svg-image-tracing-15d5bb48
Open

Abhijeet Prasad (AbhiPrasad) wants to merge 1 commit into
mainfrom
abhi/openai-svg-image-tracing-15d5bb48

Conversation

@AbhiPrasad

Copy link
Copy Markdown
Member

🤖 This text was AI-generated.

openai 3.46.0 (pinned as latest in #1082) added SVG output for image generation and a few new request params. Our tracing didn't handle them:

  • SVG images were logged with a made-up MIME type, because we built it as image/{output_format}:

    output_format="svg"  ->  image/svg      (wrong, unknown to mimetypes)
                         ->  image/svg+xml  (now)
    
  • svg_usage (token usage of the model that writes the SVG, reported separately from the image model's usage) was dropped.

  • complexity, frame_count, frame_duration_ms, svg (Images) and image, prompt_cache_options (Responses) were missing from span metadata.

Now:

  • _image_attachment_from_base64 lives in integrations/utils.py and maps svg to image/svg+xml (and a .svg filename). OpenAI and LiteLLM both use it, so LiteLLM-proxied SVG images are fixed too.

  • svg_usage is logged verbatim as metadata, not metrics. Only standard metric keys are allowed, and the SVG author can be a different model (e.g. gpt-5.6-sol), so folding its tokens into the image model's totals would misprice the span:

    images.generate span           responses.create (llm span)
      metrics:  prompt_tokens ...     └─ image_generation_call (tool span)
      metadata: svg_usage {...}           metadata: svg_usage {...}
    
  • The new params are added to the Images and Responses metadata allowlists.

The new cassette tests are gated to openai >= 3.46.0, since older matrix versions don't support SVG output. Responses image_generation_call results are still logged as raw base64 rather than attachments (true for every image format, not just SVG); that's a possible follow-up.

Closes #1084

> 🤖 **This text was AI-generated.**

openai 3.46.0 (pinned as `latest` in #1082) added SVG output for image
generation and a few new request params. Our tracing didn't handle them:

- SVG images were logged with a made-up MIME type, because we built it
  as `image/{output_format}`:

  ```
  output_format="svg"  ->  image/svg      (wrong, unknown to mimetypes)
                       ->  image/svg+xml  (now)
  ```

- `svg_usage` (token usage of the model that writes the SVG, reported
  separately from the image model's `usage`) was dropped.
- `complexity`, `frame_count`, `frame_duration_ms`, `svg` (Images) and
  `image`, `prompt_cache_options` (Responses) were missing from span
  metadata.

Now:

- `_image_attachment_from_base64` lives in `integrations/utils.py` and
  maps `svg` to `image/svg+xml` (and a `.svg` filename). OpenAI and
  LiteLLM both use it, so LiteLLM-proxied SVG images are fixed too.
- `svg_usage` is logged verbatim as metadata, not metrics. Only standard
  metric keys are allowed, and the SVG author can be a different model
  (e.g. `gpt-5.6-sol`), so folding its tokens into the image model's
  totals would misprice the span:

  ```
  images.generate span           responses.create (llm span)
    metrics:  prompt_tokens ...     └─ image_generation_call (tool span)
    metadata: svg_usage {...}           metadata: svg_usage {...}
  ```

- The new params are added to the Images and Responses metadata
  allowlists.

The new cassette tests are gated to openai >= 3.46.0, since older matrix
versions don't support SVG output. Responses `image_generation_call`
results are still logged as raw base64 rather than attachments (true for
every image format, not just SVG); that's a possible follow-up.

Closes #1084
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T20:07:32.580362Z 200404b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openai 3.46: SVG image attachments, svg_usage, and new request params

2 participants