Errors using "response_format": {"type": "json_object"}

As soon as I add ““response_format”: {“type”: “json_object”}” to my requests I get an error.

Error: {“error”:{“code”:null,“message”:“unexpected_error”,“param”:null,“type”:“unexpected_error”}}

Thank you for reaching out. We understand that you are encountering the error when adding "response_format": {"type": "json_object"} to your request.

To assist you better, could you please share the full request body you are using? This will help us identify any potential issues and provide a precise solution.

Thanks,
Prajwal

curl -X POST https://api.sambanova.ai/v1/chat/completions
-H “Content-Type: application/json”
-H “Authorization: Bearer 8…”
-d ‘{
“model”: “Meta-Llama-3.3-70B-Instruct”,
“messages”: [
{“role”: “system”, “content”: “You are helpful assistant”},
{“role”: “user”, “content”: “hello”}
],
“max_tokens”: 800,
“stream”: false,
“temperature”: 0.7,
“response_format”: {“type”: “json_object”}
}’

@hugopod

I have escalated this to our engineering teams to get this corrected. I do not have an ETA yet but will let you know when that support is enabled .

Coby

I know this is going to sound strange but the prompt needs to include the word json for this to work.

So for example:

Hello

Will say unexpected error

But:

Hello in json

Will work

Here is a working example:

curl -H “Authorization: Bearer yourapikey”
-H “Content-Type: application/json”
-d ‘{
“stream”: true,
“model”: “Meta-Llama-3.3-70B-Instruct”,
“messages”: [
{
“role”: “system”,
“content”: “You are a helpful assistant”
},
{
“role”: “user”,
“content”: “Hello in json”
}
],
“response_format”: {
“type”: “json_object”
}
}’
-X POST https://api.sambanova.ai/v1/chat/completions