Skip to main content
POST
/
api
/
v1
/
generate
/
object
Generate object
curl --request POST \
  --url https://itz.am/api/v1/generate/object \
  --header 'Api-Key: <api-key>' \
  --header 'Content-Type: application/json' \
  --data @- <<EOF
{
  "input": "Tell me about renewable energy",
  "type": "<string>",
  "callback": {
    "url": "https://example.com/callback",
    "customProperties": {},
    "headers": {}
  },
  "workflowSlug": "my_great_workflow",
  "schema": {
    "type": "object",
    "title": "User Profile",
    "description": "A user profile object",
    "properties": {
      "name": {
        "type": "string",
        "description": "The user's full name"
      },
      "age": {
        "type": "number",
        "description": "The user's age"
      },
      "interests": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "description": "List of user interests"
      }
    },
    "required": [
      "name",
      "age"
    ]
  },
  "attachments": [
    {
      "file": "file_data",
      "mimeType": "application/pdf"
    },
    {
      "file": "image_data",
      "mimeType": "image/png"
    },
    {
      "file": "https://example.com/image.jpg"
    }
  ],
  "contextSlugs": [
    "special-docs",
    "admin-files"
  ]
}
EOF
{
  "object": {},
  "metadata": {
    "runId": "run_1234567890",
    "cost": "0.001",
    "model": {
      "name": "gpt-4o",
      "tag": "openai:gpt-4o"
    },
    "durationInMs": 1000,
    "inputTokens": 1000,
    "outputTokens": 1000
  }
}

Authorizations

Api-Key
string
header
required

The API key to use for authentication

Body

application/json
  • Option 1
  • Option 2
input
string
required

The input text to generate a response for

Minimum string length: 1
Example:

"Tell me about renewable energy"

type
string
required
Allowed value: "event"
callback
object
required
workflowSlug
string
required

The slug of the Workflow to use for generation

Example:

"my_great_workflow"

schema
any
required

A valid JSON Schema object defining the structure of the expected response. Must have a 'type' property set to 'object', 'array', or 'string' (with enum). See https://json-schema.org/ for full specification.

Example:
{
"type": "object",
"title": "User Profile",
"description": "A user profile object",
"properties": {
"name": {
"type": "string",
"description": "The user's full name"
},
"age": {
"type": "number",
"description": "The user's age"
},
"interests": {
"type": "array",
"items": { "type": "string" },
"description": "List of user interests"
}
},
"required": ["name", "age"]
}
attachments
object[]

Optional attachments to include in the generation

Example:
[
{
"file": "file_data",
"mimeType": "application/pdf"
},
{
"file": "image_data",
"mimeType": "image/png"
},
{ "file": "https://example.com/image.jpg" }
]
contextSlugs
string[]

Optional context slugs to add contexts to the run

Example:
["special-docs", "admin-files"]

Response

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

object
object
required

The generated object based on the provided schema

metadata
object
required