output-schema.json 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {
  2. "_comment": "Canonical structured-outputs request body for the Anthropic Messages API. Pass the `output_config` object below in client.messages.create(...). This is the current `output_config.format` shape — NOT the deprecated top-level `output_format` param. Adapt `schema.properties` and `required` to your data; keep `additionalProperties: false` so the model can't add stray keys. Supported on Opus 4.8/4.7/4.6/4.5, Sonnet 4.6/4.5, Haiku 4.5 — NOT Fable 5 (use system-prompt instructions or strict tool use there).",
  3. "model": "claude-opus-4-8",
  4. "max_tokens": 1024,
  5. "messages": [
  6. {
  7. "role": "user",
  8. "content": "Extract the contact: Jane Doe (jane@example.com) wants the Enterprise plan and asked for a demo."
  9. }
  10. ],
  11. "output_config": {
  12. "format": {
  13. "type": "json_schema",
  14. "schema": {
  15. "type": "object",
  16. "properties": {
  17. "name": {
  18. "type": "string",
  19. "description": "Full name of the contact"
  20. },
  21. "email": {
  22. "type": "string",
  23. "format": "email"
  24. },
  25. "plan": {
  26. "type": "string",
  27. "enum": ["Free", "Pro", "Enterprise"]
  28. },
  29. "demo_requested": {
  30. "type": "boolean",
  31. "description": "Whether the contact asked for a demo"
  32. }
  33. },
  34. "required": ["name", "email", "plan", "demo_requested"],
  35. "additionalProperties": false
  36. }
  37. }
  38. }
  39. }