> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentmark.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Generating objects

> Generate structured JSON objects from prompts with schema validation using AgentMark.

AgentMark generates structured objects with prompts that declare `object_config` in frontmatter and a JSON schema for the expected output. Object prompts use the same message-role tags as text prompts.

## Example configuration

```jsx example.prompt.mdx theme={null}
---
name: example
object_config:
  model_name: openai/gpt-5
  schema:
    type: object
    properties:
      event:
        type: object
        properties:
          name: 
            type: string
            description: The name of the event
          date:
            type: string
            description: The date of the event
          attendees:
            type: array
            items:
              type: object
              properties:
                name:
                  type: string
                  description: The name of the attendee
                role:
                  type: string
                  description: The role of the attendee
              required:
                - name
                - role
        required: 
          - name
          - date
          - attendees
---

<System>You are an event planner that creates detailed event objects with attendees and their roles.</System>
<User>Create an event for a team meeting next Friday with John as the facilitator and Sarah as the note-taker.</User>
```

<Warning>
  **OpenAI strict structured output requires `additionalProperties: false` on every object** in your `schema` (the root and each nested object) and a `required` list naming all of that object's properties. Zod's `z.object().strict()` emits this for you; a hand-written or migrated JSON-schema `schema` block doesn't, so it's the most common Zod→frontmatter migration trap. Omit it and OpenAI rejects the request with a strict-schema validation error. (Providers without strict mode ignore the field, so it's always safe to add.)
</Warning>

## Tags

| Tag           | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| `<System>`    | System-level instructions                                   |
| `<User>`      | User message                                                |
| `<Assistant>` | Assistant message (optional; include for few-shot examples) |

## Using schema references

Instead of writing a full schema inline, you can extract it into a `.json` file and use `$ref` to reference it. AgentMark resolves the reference at build time.

```jsx extract-event.prompt.mdx theme={null}
---
name: extract-event
object_config:
  model_name: openai/gpt-5
  schema:
    $ref: ./schemas/event.json
---

<System>You are an event planner that creates detailed event objects.</System>
<User>Create an event for a team meeting next Friday with John as the facilitator.</User>
```

See [Schema references](/build/schema-references) for full documentation on `$ref` syntax, transitive references, and JSON Pointer fragments.

## Available configuration

| Property             | Type         | Description                                                                                                                                                            | Required |
| -------------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `model_name`         | `string`     | The name of the model to use for object generation.                                                                                                                    | Yes      |
| `schema`             | `JSONSchema` | Schema defining the expected structure of the model's output. Supports [`$ref`](/build/schema-references) for reusable definitions.                                    | Yes      |
| `max_tokens`         | `number`     | Maximum number of tokens to generate.                                                                                                                                  | No       |
| `temperature`        | `number`     | Controls the randomness of the output; higher values are more random.                                                                                                  | No       |
| `max_calls`          | `number`     | Maximum number of LLM calls allowed.                                                                                                                                   | No       |
| `top_p`              | `number`     | Cumulative probability for nucleus sampling.                                                                                                                           | No       |
| `top_k`              | `number`     | Limits next-token selection to the top `k` tokens.                                                                                                                     | No       |
| `presence_penalty`   | `number`     | Penalizes tokens based on presence in the text so far.                                                                                                                 | No       |
| `frequency_penalty`  | `number`     | Penalizes tokens based on frequency in the text so far.                                                                                                                | No       |
| `stop_sequences`     | `string[]`   | Strings that, if encountered, stop generation.                                                                                                                         | No       |
| `seed`               | `number`     | Random-number seed for reproducibility.                                                                                                                                | No       |
| `max_retries`        | `number`     | Maximum number of retries on failure.                                                                                                                                  | No       |
| `schema_name`        | `string`     | Name sent with the schema (used by OpenAI structured outputs).                                                                                                         | No       |
| `schema_description` | `string`     | Description sent with the schema.                                                                                                                                      | No       |
| `tools`              | `string[]`   | List of tool names or MCP URIs available to the model. You resolve these names to implementations at your call site (see [Tools and agents](/build/tools-and-agents)). | No       |

## Running an object prompt

See the **SDK usage** section of [Running prompts](/build/running-prompts) (under the **Local** tab) for the object-generation SDK code patterns: render the prompt with `prompt.format()`, then make your own structured-output call (`generateObject` / `streamObject` in TypeScript, the OpenAI client in Python).

<div className="mt-8 rounded-lg bg-blue-50 p-6 dark:bg-blue-900/30">
  <h3 className="font-semibold mb-3">Have questions?</h3>
  <p className="mb-4">Reach out any time:</p>

  <ul>
    <li>
      Email the team at <a href="mailto:hello@agentmark.co" className="text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200">[hello@agentmark.co](mailto:hello@agentmark.co)</a> for support
    </li>

    <li>
      Schedule an <a href="https://cal.com/ryan-randall/enterprise" className="text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200">Enterprise Demo</a> to learn about AgentMark's business solutions
    </li>
  </ul>
</div>
