JSON Response in Claude.AI , OpenAI, Gemini

I found that it’s much easier to get JSON responses with Claude.AI compared to OpenAI and Gemini. While OpenAI and Gemini provide JSON as a string in their responses, which is in JSON-SAFE mode, Claude.AI allows you to request JSON directly, and you receive it as an object within the response body, not as a string. This makes it easy to navigate the JSON.

This is extremely helpful because when I was using OpenAI and Gemini, it was a headache to work with their JSON responses. The API connector detects them as strings, and converting them to JSON is a lengthy process that requires extra effort.

3 Likes

Can you share a link to the Anthropic docs that explains this please?

You have to use a tool which tell the JSON output we want, and then once we get the response it will be an object of that json schema which we ask for in tools. the object can also contain an array or a dictionary.

and also remember, Tools need to implemented in API call, not like we do in OPNE AI where we define a function and reference that function name in api call.

In Anthropic we will define the function inside the api call