https://www.boundaryml.com logo
debugging OpenRouter "Failed to parse JSON" error
# questions
d
Hi I have a question, we see an error when using
OpenRouter
, our trace starts off like this:
Copy code
BamlClientHttpError(client_name=OpenRouterLlama4Maverick, message=LLM call failed: LLMErrorResponse { client: "OpenRouterLlama4Maverick", model: None, prompt: Chat([RenderedChatMessage { role: "system", allow_duplicate_role: false, parts:<lots of info>
and ends with this error message:
Copy code
message: "Failed to parse JSON: EOF while parsing a value at line 1 column 0", code: Other(200) }, status_code=200)
We're using
OpenRouter
as our provider to allow for provider routing, however it's hard to tell if this error is on the BAML or the provider side. We want to verify that
OpenRouter
should be the one falling back here or if the BAML is getting back a bad JSON payload (but a 200 response) from the LLM provider which is why this error is coming up.
b
Is there any chance you can share a more complete error message?
Oh, actually, sorry - re-reading your message this is not BAML getting back a bad JSON payload
In that case, we throw BamlValidationError
If you can reproduce this in the BAML playground, you can also use the "raw curl" view to debug the openrouter interaction
[Here's the documentation about different BAML error types](https://docs.boundaryml.com/guide/baml-basics/error-handling#bamlvalidationerror)
Does this help?
d
Yeah I re-ran it and it worked in the playground - unfortunately the payload has PII in it so I can't send it. It's confusing though because the status code received is 200 with the error above.
It's an intermittent error for sure, but I wonder if we can reproduce a more minimal version.
Have you ever seen it return with a 200 status code?
b
Does it reproduce at all with the “raw curl” command?
The playground also has “raw response” toggles in the dropdown above the test result
I don’t think we’ve seen 200 with ClientHttpError, but bugs are always possible
d
It does not reproduce sadly 😦
b
Hmm- OK, I’ll take some time tomorrow to look at this or see if there’s something we can play around with.
Sorry that this is being so tricky to figure out 😦
d
No worries, appreciate the help. It's definitely a weird one.
b
Hey, just wanted to let you know I haven't forgotten about this despite the radio silence. Unfortunately I haven't had a moment to context switch onto this, but it's close to the top of my todo list!
Do let me know if you manage to get a more minimal repro