MrWhiteee
11/09/2025, 12:45 AMgemini-2.5-flash-image ) and this was my setup:
client<llm> AdsGeminiImageEdit {
provider vertex-ai
retry_policy Exponential
options {
model "gemini-2.5-flash-image"
location "europe-west1"
credentials env.GOOGLE_PROJECT_SECRET
generationConfig {
maxOutputTokens 32768
temperature 1
}
media_url_handler {
image "send_url_add_mime_type"
}
}
}
function EditAdImage(
prompt: string,
referenceImages: image[],
) -> image {
client AdsGeminiImageEdit
prompt #"
You are an expert marketing image editor. ...
{{ _.role("user") }}
Prompt:
{{ prompt }}
Reference Images:
{% for image in referenceImages %}
{{ image }}
{% endfor %}
"#
}
FIrst of all, interesting behavior if " {{ ctx.output_format }}" is written at the end of the prompt:
thread 'tokio-runtime-worker' panicked at library/alloc/src/fmt.rs:650:14:
a formatting trait implementation returned an error when the underlying stream did not: Error
2025-11-09T01:19:41.316 [BAML ERROR]
But after removing it, I get this instead:
...
...chGvN9nEAAAAASUVORK5CYII="}}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":1621,"candidatesTokenCount":1290,"totalTokenCount":2911,"trafficType":"ON_DEMAND","promptTokensDetails":[{"modality":"TEXT","tokenCount":1105},{"modality":"IMAGE","tokenCount":516}],"candidatesTokensDetails":[{"modality":"IMAGE","tokenCount":1290}]},"modelVersion":"gemini-2.5-flash-image","createTime":"2025-11-09T00:37:28.452545Z","responseId":"SOIPacHPG6_h_c8Prr-Z8AM"}
Caused by:
missing field `text`
I am running baml-cli 0.213.0greg (BAML)
11/09/2025, 12:51 AMgreg (BAML)
11/09/2025, 12:53 AMMrWhiteee
11/09/2025, 12:57 AMgreg (BAML)
11/09/2025, 1:36 AMgreg (BAML)
11/09/2025, 1:37 AMMrWhiteee
11/09/2025, 8:33 AMMrWhiteee
11/09/2025, 2:08 PMUnspecified error code: 2 Failed to parse into a response accepted by baml_runtime::internal::llm_client::primitive::vertex::types::VertexResponse: {"candidates":[{"content":{"role":"model","parts":[{"inlineData":{"mimeType":"image/png","data":"iVBORw0KGgoAA ... I="}}]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":608,"candidatesTokenCount":1290,"totalTokenCount":1898,"trafficType":"ON_DEMAND","promptTokensDetails":[{"modality":"IMAGE","tokenCount":516},{"modality":"TEXT","tokenCount":92}],"candidatesTokensDetails":[{"modality":"IMAGE","tokenCount":1290}]},"modelVersion":"gemini-2.5-flash-image","createTime":"2025-11-09T13:10:45.558212Z","responseId":"1ZIQaYSJIuWzmPUPwLHPyQU"}
Caused by:
missing field `text`
Request options: {"generationConfig":{"maxOutputTokens":32768,"temperature":1,"responseModalities":["TEXT","IMAGE"]}}
I tried to remove text modality, still same error. I did actually see the text for a split second in the BAML Playground, but after that it just errored.
I was trying to figure this out with Codex and got this answer:
What you’re seeing now confirms the Vertex provider in the current BAML runtime can’t handle inlineData at all. Even though we force the model to add a text summary, the response still contains a second part with just inlineData. The runtime tries to deserialize each part into a struct that requires a text field, hits the image part, and throws missing field 'text' before your function ever sees the payload.
It recommends me to Bypass BAML’s LLM client and call Vertex directly (a small proxy you can hit from BAML). but I have looked around and didn't see any support of custom client or something like that.MrWhiteee
11/09/2025, 2:10 PMclient<llm> AdsGeminiImageEdit {
provider vertex-ai
// retry_policy Exponential
options {
model "gemini-2.5-flash-image"
location "europe-west1"
credentials env.GOOGLE_PROJECT_SECRET
generationConfig {
maxOutputTokens 32768
temperature 1
responseModalities ["TEXT", "IMAGE"]
}
media_url_handler {
image "send_url_add_mime_type"
}
}
}
class GeminiInlineData {
mimeType string?
data string?
}
class GeminiPart {
inlineData GeminiInlineData?
text string?
}
class GeminiContent {
role string?
parts GeminiPart[]
}
class GeminiCandidate {
content GeminiContent?
finishReason string?
index int?
}
class GeminiTokensDetail {
modality string?
tokenCount int?
}
class GeminiUsageMetadata {
promptTokenCount int?
candidatesTokenCount int?
totalTokenCount int?
trafficType string?
promptTokensDetails GeminiTokensDetail[]?
candidatesTokensDetails GeminiTokensDetail[]?
}
class GeminiImageEditResponse {
candidates GeminiCandidate[]?
usageMetadata GeminiUsageMetadata?
modelVersion string?
createTime string?
responseId string?
}
function EditAdImage(
prompt: string,
referenceImages: image[],
) -> GeminiImageEditResponse {
client AdsGeminiImageEditgreg (BAML)
11/09/2025, 2:56 PMMrWhiteee
11/09/2025, 3:02 PMgreg (BAML)
11/09/2025, 3:07 PMgreg (BAML)
11/09/2025, 3:08 PMMrWhiteee
11/09/2025, 3:12 PM