---
title: "Generate object"
method: POST
path: "/api/v1/generate/object"
---

# Generate object

`POST /api/v1/generate/object`

Generate a structured object for a specific workflow

## Request body

- AiStructuredCompletionRequest
  - `input` string, required — The input text to generate a response for
  - `workflowSlug` string, required — The slug of the Workflow to use for generation (can be found in the Itzam dashboard)
  - `groupId` string — Optional identifier for grouping related runs (e.g. user ID, session ID, etc.)
  - `schema` object — The schema of the response, JSON Schema

## Response `200`

Successfully generated object (we also return the run ID in the header X-Run-ID)

- GenerateObjectResponse
  - `object` unknown
  - `metadata` object, required
    - `runId` string, required — The ID of the run created for this generation
    - `cost` string, required — The cost of the run
    - `model` object, required
      - `name` string, required — The name of the model used for this generation
      - `tag` string, required — The tag of the model used for this generation
    - `durationInMs` number, required — The duration of the run in milliseconds
    - `inputTokens` number, required — The number of input tokens used for this generation
    - `outputTokens` number, required — The number of output tokens used for this generation

## Other responses

- `400` — Bad request - invalid input
- `401` — Unauthorized - invalid API key
- `404` — Not found - workflow not found
- `500` — Server error during generation

---

[API](https://skmtc.dev/itzam-ai/apis/itzam-api.md) · [All operations](https://skmtc.dev/itzam-ai/apis/itzam-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/itzam-ai/itzam-api/revisions/cc21b9e9916a/schema)
