Use response_format with a JSON Schema and the model returns strictly structured JSON your code can parse directly.
curl https://tokendog.io/v1/chat/completions \
-H "Authorization: Bearer $TOKENDOG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model":"gpt-5",
"messages":[{"role":"user","content":"Extract: John Doe, age 28"}],
"response_format":{"type":"json_schema","json_schema":{
"name":"person","schema":{"type":"object",
"properties":{"name":{"type":"string"},"age":{"type":"integer"}},
"required":["name","age"],"additionalProperties":false}}}
}'
The content is a schema-conforming JSON string — parse it directly with JSON.parse / json.loads.