C.W.K.
Stream
Lesson 03 of 10 · published

OpenAI — JSON Mode, Function Calling, Reasoning

~14 min · providers, openai

Level 0Apprentice
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

What OpenAI does well

  • Strict JSON Schema mode (response_format with json_schema, strict: true).
  • Mature function calling with parallel calls.
  • o-series and GPT-5.5 reasoning with effort levels.
  • Multimodal across text, vision, audio.
  • Realtime API for low-latency voice.

Quirks to know

  • Three roles: system, developer, user. Developer is for app-level instructions that should outrank user but be invisible to users.
  • Reasoning tokens are billed but not returned to the developer (you see the answer, not the trace).
  • Strict JSON Schema mode supports a subset of JSON Schema — not all keywords are accepted.
  • Function-call style: arguments are returned as a JSON string you parse, not a parsed object.

Style preferences

OpenAI models respond well to terse, imperative system prompts and well-described function definitions. Heavy XML-tag scaffolding can interfere; keep it lighter than on Claude.

Code

OpenAI — strict structured output + reasoning·python
import openai

client = openai.OpenAI()
resp = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "system", "content": "You are a contract analyst."},
              {"role": "user", "content": question}],
    response_format={
        "type": "json_schema",
        "json_schema": {"name": "findings", "strict": True, "schema": SCHEMA}
    },
    reasoning={"effort": "high"},
    max_completion_tokens=2048,
)

External links

Exercise

Migrate one prompt from a non-strict 'please return JSON' style to OpenAI strict JSON Schema mode. Note the prompt simplifications you can make once the schema is enforced.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.