-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Feature requestNew feature requestNew feature request
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
OpenAI URL handling is very unstable it seems (plenty of issues in their forum with regressions after it was fixed)
https://community.openai.com/t/invalid-image-url-error-code-for-image-urls-without-file-extension/1141898
https://community.openai.com/t/invalid-image-error-in-gpt-4o-when-using-s3-presigned-url/794549
https://community.openai.com/t/invalid-image-error-in-gpt-4-vision/505843/18
Pydatnic AI is sending urls, considering the unstable nature of this feature on the OpenAI side of things would it make sense to move to sending base64 strings instead?
Below is some code to recreate the issue on the openai side and pyndatic side of things (same error)
Example Code
import httpx
from openai import OpenAI
from pydantic_ai import Agent, ImageUrl
client = OpenAI()
url = "https://graph.facebook.com/NASA/picture?type=large"
data = httpx.get(url, follow_redirects=True).content
# assert data
print("Image URL is valid", len(data), "bytes")
try:
response = client.chat.completions.create(
model="gpt-5",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {"url": url},
},
],
}
],
)
except Exception as e:
print("Error from OpenAI:", e)
agent = Agent(model="gpt-5")
response = agent.run_sync(
[
"What is in this image?",
ImageUrl(
url=url,
media_type="image/png",
),
]
)
Python, Pydantic AI & LLM client version
pydantic-ai: 1.0.15
Metadata
Metadata
Assignees
Labels
Feature requestNew feature requestNew feature request