Open
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Running the official OpenAI SDK test code in a Jupyter Notebook causes the following error:
UnicodeEncodeError: 'ascii' codec can't encode character '\u2014' in position 110: ordinal not in range(128)
The test script appears to fail in Jupyter due to UnicodeEncodeError from an em dash \u2014, and Jupyter's sys.stdout is not reconfigurable. I think this makes the default SDK examples unusable in Jupyter by default.
To Reproduce
Launch a Jupyter Notebook from terminal
Create a new Python 3 notebook
Paste and run the following code cell
Code snippets
from openai import OpenAI
import base64
client = OpenAI()
response = client.responses.create(
model="gpt-4.1-mini",
input="Generate an image of gray tabby cat hugging an otter with an orange scarf",
tools=[{"type": "image_generation"}],
)
I got it form this image generation example
The notebook crashes with a UnicodeEncodeError, and Jupyter’s I/O wrappers don’t allow easy reconfiguration of encoding.
OS
macOS
Python version
Python 3.13.4
Library version
openai 1.85.0