Prompt

structured JSON output api

Artificial Intelligence / AI Platforms2 observationsLast seen Nov 14, 2026

Latest observation

Nov 14, 2026OpenAI APIWeb search: off

If you want an API to return structured JSON output, you usually mean one of these:

  1. Your API should always respond with valid JSON
  2. You want to enforce a specific JSON schema/shape
  3. You want an AI model/API to generate JSON only

Example of structured JSON response

{
  "status": "success",
  "data": {
    "id": 123,
    "name": "Alice",
    "email": "alice@example.com"
  }
}

Common ways to enforce structured JSON

1. In a normal web API

Return a JSON object from your backend:

  • Node/Express
res.json({
  status: "success",
  data: { id: 123, name: "Alice" }
});
  • Python/FastAPI
return {"status": "success", "data": {"id": 123, "name": "Alice"}}

2. With schema validation

Define a schema so the response must match it:

  • JSON Schema
  • Pydantic
  • Zod
  • OpenAPI/Swagger

3. For AI model output

If you’re using an LLM API, ask for JSON explicitly and validate it afterward. Some APIs also support structured outputs / JSON schema mode.

Example prompt:

Return only valid JSON with keys: name, age, city.

Example output:

{"name":"Alice","age":30,"city":"London"}

Best practice

  • Always set Content-Type: application/json
  • Validate output against a schema
  • Reject or repair invalid JSON
  • Keep the JSON shape consistent

If you want, I can show you how to do this in:

  • Python
  • Node.js
  • OpenAI API
  • FastAPI / Express / Django / Flask

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.