Support PDF data URIs as image_url for Vertex AI's OpenAI-compatible endpoint #7159
moinudeen
started this conversation in
Feature Requests
Replies: 1 comment
-
|
Hi @moinudeen thanks for the detailed feature request. We may build something a bit more flexible but will be sure to cover your case explicitly. Sorry for the inconvenience, we'll try to have this fixed soon! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
We're using TensorZero with Vertex AI's OpenAI-compatible endpoint (
type = "openai"provider pointing at Vertex AI's/openapipath). Everything works great for text and images, but sending PDFs breaks.What happens
When we send a PDF as
image_urlwith adata:application/pdf;base64,...data URI, TZ's OpenAI provider detects it's not an image, resolves it, and re-serializes it as atype: "file"content block.The problem is that Vertex AI's OpenAI-compatible endpoint doesn't support
type: "file":What we tested
We tested every format we could find, both directly against Vertex AI and through TZ:
image_url+data:application/pdf;base64,...type:file, Vertex AI rejectstype:file+file_data(OpenAI's format)image_url+gs://URIimage_url+ signed HTTPS URL to PDFThe only format Vertex AI accepts for PDFs is
data:application/pdf;base64,...insideimage_urlblocks — and TZ converts that totype: "file"before it reaches Vertex AI.Community confirmation that this format works: https://discuss.ai.google.dev/t/openai-compatibility-for-pdf-file/77388
Why we use
type = "openai"for Vertex AIVertex AI's OpenAI-compatible endpoint handles
response_format: json_schemawith complex nested schemas better than the native Gemini API. We rely on this for structured extraction with Instructor, sogcp_vertex_geminiisn't an option for us right now.Idea
Would it be possible to add a per-provider option that keeps non-image files as
image_urldata URIs instead of converting them totype: "file"? Something like:The change would be in
prepare_file_message()— in the catch-all branch that currently createsOpenAIContentBlock::File, it would instead createOpenAIContentBlock::ImageUrlwith thedata:{mime};base64,...URL when this option is set.Related
type: "file"to the OpenAI provider — works for real OpenAI, not Vertex AIgcp_vertex_geminiprovider usingInlineData— works greatlet me know if this makes sense. I can raise a PR for this if you are open to this approach or happy to learn about your opinions on this.
Beta Was this translation helpful? Give feedback.
All reactions