---
title: "Generate structured JSON response"
method: POST
path: "/generate-object"
tags: ["Generation"]
---

# Generate structured JSON response

`POST /generate-object`

Generates structured JSON response from Claude CLI. The schema is passed in the request to instruct Claude to output valid JSON.

## Request body

- object
  - `system` string
  - `prompt` string, required
  - `sessionId` string
  - `model` string
  - `allowedTools` string[]
  - `schema` object, required
    - `type` 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null'
    - `properties` object
    - `items` unknown
    - `$ref` string
    - `allOf` unknown[]
      - unknown
    - `anyOf` unknown[]
      - unknown
    - `oneOf` unknown[]
      - unknown
    - `enum` unknown[]
      - unknown
    - `const` unknown
  - `maxTokens` integer

## Response `200`

Successful object generation

- object
  - `object` unknown
  - `rawText` string, required
  - `usage` object, required
    - `inputTokens` integer, required
    - `outputTokens` integer, required
    - `totalTokens` integer, required
  - `sessionId` string, required

## Other responses

- `400` — Validation error
- `401` — Missing authorization header
- `403` — Invalid API key
- `500` — Internal server error or CLI error

## Changes

- **2026-07-17** `f7074f1efbee` — 2 warning, 1 info
  - added the new `NO_TOOLS_AVAILABLE` enum value to the `code` response property for the response status `400`
  - added the new `NO_TOOLS_AVAILABLE` enum value to the `code` response property for the response status `500`
  - added the new optional request property `allowedTools`
- **2025-12-27** `b62b4ac2e1b7` — 1 warning
  - removed the request property `userEmail`
- **2025-12-27** `3575d0f3e416` — 9 info
  - added the new optional request property `schema/$ref`
  - added the new optional request property `schema/allOf`
  - added the new optional request property `schema/anyOf`
  - added the new optional request property `schema/const`
  - …5 more
- **2025-12-27** `5aa7ce43bc12` — 1 breaking, 1 warning
  - the `maxTokens` request property type/format changed from `number`/`` to `integer`/``
  - the `maxTokens` request property's exclusiveMinimum was set to `0.00`
- **2025-12-26** `5a0fb0ffd413` — 2 warning
  - added the new `CONCURRENCY_LIMIT_ERROR` enum value to the `code` response property for the response status `400`
  - added the new `CONCURRENCY_LIMIT_ERROR` enum value to the `code` response property for the response status `500`

[Full history](https://skmtc.dev/pattern-zones-co/apis/koine-gateway-api/changes/generate-object/post.md)

---

[API](https://skmtc.dev/pattern-zones-co/apis/koine-gateway-api.md) · [All operations](https://skmtc.dev/pattern-zones-co/apis/koine-gateway-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/pattern-zones-co/koine-gateway-api/revisions/f7074f1efbee/schema)
