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

# Prompts & Artifact Schemas

> Create reusable prompts and define structured output schemas for agents

# Prompts & Artifact Schemas

Prompts and artifact schemas let you define reusable building blocks for agent behavior. Prompts provide templated instructions that can be shared across agents, while artifact schemas define the structured output format agents should produce.

## Create a prompt

Create a reusable prompt template. Prompts can include variables using double-brace syntax (e.g., `{{topic}}`) that are filled in at runtime.

<CodeGroup>
  ```python Python theme={null}
  import os
  from meibel import MeibelClient
  from meibel.models import CreateAgentPromptRequest

  client = MeibelClient(api_key=os.environ["MEIBEL_API_KEY"])

  prompt = client.prompts.create_prompt(body=CreateAgentPromptRequest(
      name="summarize-document",
      description="Summarizes a document with key takeaways",
      content="Summarize the following document in {{length}} bullet points. Focus on {{focus_area}}. Include citations for each point.",
  ))

  print(prompt.id, prompt.name)
  ```

  ```typescript TypeScript theme={null}
  import { MeibelClient } from 'meibel';

  const client = new MeibelClient({ apiKey: process.env.MEIBEL_API_KEY });

  const prompt = await client.prompts.createPrompt({
    name: 'summarize-document',
    description: 'Summarizes a document with key takeaways',
    content: 'Summarize the following document in {{length}} bullet points. Focus on {{focus_area}}. Include citations for each point.',
  });

  console.log(prompt.id, prompt.name);
  ```

  ```go Go theme={null}
  import (
      "context"
      "fmt"
      "os"

      meibel "github.com/meibel-ai/meibel-go"
  )

  client := meibel.NewClient(meibel.WithAPIKey(os.Getenv("MEIBEL_API_KEY")))
  ctx := context.Background()

  prompt, err := client.Prompts.CreatePrompt(ctx, meibel.CreateAgentPromptRequest{
      Name:        "summarize-document",
      Description: "Summarizes a document with key takeaways",
      Content:     "Summarize the following document in {{length}} bullet points. Focus on {{focus_area}}. Include citations for each point.",
  })
  if err != nil {
      log.Fatal(err)
  }

  fmt.Println(prompt.ID, prompt.Name)
  ```

  ```bash CLI theme={null}
  meibel prompts create --data '{
    "name": "summarize-document",
    "description": "Summarizes a document with key takeaways",
    "content": "Summarize the following document in {{length}} bullet points. Focus on {{focus_area}}. Include citations for each point."
  }'
  ```
</CodeGroup>

The response includes the prompt `id`, `name`, `description`, and `content`. Use the `id` to reference the prompt from agents or other API calls.

## Get a prompt

Retrieve the full details of an existing prompt.

<CodeGroup>
  ```python Python theme={null}
  prompt = client.prompts.get_prompt(prompt_id="prompt_123")

  print(prompt.name)
  print(prompt.content)
  ```

  ```typescript TypeScript theme={null}
  const prompt = await client.prompts.getPrompt('prompt_123');

  console.log(prompt.name);
  console.log(prompt.content);
  ```

  ```go Go theme={null}
  prompt, err := client.Prompts.GetPrompt(ctx, "prompt_123")
  if err != nil {
      log.Fatal(err)
  }

  fmt.Println(prompt.Name)
  fmt.Println(prompt.Content)
  ```

  ```bash CLI theme={null}
  meibel prompts get prompt_123
  ```
</CodeGroup>

## Update a prompt

Modify a prompt's name, description, or content. Only the fields you include are changed.

<CodeGroup>
  ```python Python theme={null}
  from meibel.models import UpdateAgentPromptRequest

  updated = client.prompts.update_prompt(
      prompt_id="prompt_123",
      body=UpdateAgentPromptRequest(
          content="Provide a {{length}}-point summary of the document. Focus on {{focus_area}}. Cite sources with page numbers.",
      ),
  )

  print(updated.content)
  ```

  ```typescript TypeScript theme={null}
  const updated = await client.prompts.updatePrompt('prompt_123', {
    content: 'Provide a {{length}}-point summary of the document. Focus on {{focus_area}}. Cite sources with page numbers.',
  });

  console.log(updated.content);
  ```

  ```go Go theme={null}
  updated, err := client.Prompts.UpdatePrompt(ctx, "prompt_123", meibel.UpdateAgentPromptRequest{
      Content: "Provide a {{length}}-point summary of the document. Focus on {{focus_area}}. Cite sources with page numbers.",
  })
  if err != nil {
      log.Fatal(err)
  }

  fmt.Println(updated.Content)
  ```

  ```bash CLI theme={null}
  meibel prompts update prompt_123 --data '{
    "content": "Provide a {{length}}-point summary of the document. Focus on {{focus_area}}. Cite sources with page numbers."
  }'
  ```
</CodeGroup>

<Note>
  Updating a prompt does not affect agents that have already been published with the old version. Only new sessions or republished agents pick up the changes.
</Note>

## Delete a prompt

Permanently remove a prompt. This action cannot be undone.

<CodeGroup>
  ```python Python theme={null}
  client.prompts.delete_prompt(prompt_id="prompt_123")
  ```

  ```typescript TypeScript theme={null}
  await client.prompts.deletePrompt('prompt_123');
  ```

  ```go Go theme={null}
  err := client.Prompts.DeletePrompt(ctx, "prompt_123")
  if err != nil {
      log.Fatal(err)
  }
  ```

  ```bash CLI theme={null}
  meibel prompts delete prompt_123
  ```
</CodeGroup>

## Create an artifact schema

Artifact schemas define the structured output format that an agent should produce. Use JSON Schema to specify the fields, types, and validation rules.

<CodeGroup>
  ```python Python theme={null}
  from meibel.models import CreateAgentArtifactRequest

  schema = client.artifact_schemas.create_artifact_schema(body=CreateAgentArtifactRequest(
      name="meeting-summary",
      description="Structured output for meeting summaries",
      schema={
          "type": "object",
          "properties": {
              "title": {"type": "string", "description": "Meeting title"},
              "date": {"type": "string", "format": "date"},
              "attendees": {
                  "type": "array",
                  "items": {"type": "string"},
              },
              "action_items": {
                  "type": "array",
                  "items": {
                      "type": "object",
                      "properties": {
                          "description": {"type": "string"},
                          "assignee": {"type": "string"},
                          "due_date": {"type": "string", "format": "date"},
                      },
                      "required": ["description"],
                  },
              },
              "key_decisions": {
                  "type": "array",
                  "items": {"type": "string"},
              },
          },
          "required": ["title", "date", "action_items"],
      },
  ))

  print(schema.id, schema.name)
  ```

  ```typescript TypeScript theme={null}
  const schema = await client.artifactSchemas.createArtifactSchema({
    name: 'meeting-summary',
    description: 'Structured output for meeting summaries',
    schema: {
      type: 'object',
      properties: {
        title: { type: 'string', description: 'Meeting title' },
        date: { type: 'string', format: 'date' },
        attendees: {
          type: 'array',
          items: { type: 'string' },
        },
        actionItems: {
          type: 'array',
          items: {
            type: 'object',
            properties: {
              description: { type: 'string' },
              assignee: { type: 'string' },
              dueDate: { type: 'string', format: 'date' },
            },
            required: ['description'],
          },
        },
        keyDecisions: {
          type: 'array',
          items: { type: 'string' },
        },
      },
      required: ['title', 'date', 'actionItems'],
    },
  });

  console.log(schema.id, schema.name);
  ```

  ```go Go theme={null}
  schema, err := client.ArtifactSchemas.CreateArtifactSchema(ctx, meibel.CreateAgentArtifactRequest{
      Name:        "meeting-summary",
      Description: "Structured output for meeting summaries",
      Schema: map[string]interface{}{
          "type": "object",
          "properties": map[string]interface{}{
              "title":     map[string]interface{}{"type": "string", "description": "Meeting title"},
              "date":      map[string]interface{}{"type": "string", "format": "date"},
              "attendees": map[string]interface{}{"type": "array", "items": map[string]interface{}{"type": "string"}},
              "action_items": map[string]interface{}{
                  "type": "array",
                  "items": map[string]interface{}{
                      "type": "object",
                      "properties": map[string]interface{}{
                          "description": map[string]interface{}{"type": "string"},
                          "assignee":    map[string]interface{}{"type": "string"},
                          "due_date":    map[string]interface{}{"type": "string", "format": "date"},
                      },
                      "required": []string{"description"},
                  },
              },
              "key_decisions": map[string]interface{}{
                  "type":  "array",
                  "items": map[string]interface{}{"type": "string"},
              },
          },
          "required": []string{"title", "date", "action_items"},
      },
  })
  if err != nil {
      log.Fatal(err)
  }

  fmt.Println(schema.ID, schema.Name)
  ```

  ```bash CLI theme={null}
  meibel artifact-schemas create --data '{
    "name": "meeting-summary",
    "description": "Structured output for meeting summaries",
    "schema": {
      "type": "object",
      "properties": {
        "title": {"type": "string", "description": "Meeting title"},
        "date": {"type": "string", "format": "date"},
        "attendees": {"type": "array", "items": {"type": "string"}},
        "action_items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "description": {"type": "string"},
              "assignee": {"type": "string"},
              "due_date": {"type": "string", "format": "date"}
            },
            "required": ["description"]
          }
        },
        "key_decisions": {"type": "array", "items": {"type": "string"}}
      },
      "required": ["title", "date", "action_items"]
    }
  }'
  ```
</CodeGroup>

## Use a schema with an agent

Reference an artifact schema when creating or updating an agent so that its responses conform to the defined structure.

<CodeGroup>
  ```python Python theme={null}
  from meibel.models import CreateAgentDefinitionRequest

  agent = client.agents.create_agent(body=CreateAgentDefinitionRequest(
      display_name="Meeting Summarizer",
      description="Produces structured meeting summaries",
      instructions="You are a meeting summarizer. Extract key information and format it according to the provided schema.",
      artifacts=[schema.id],
  ))

  print(agent.id, agent.artifacts)
  ```

  ```typescript TypeScript theme={null}
  const agent = await client.agents.createAgent({
    displayName: 'Meeting Summarizer',
    description: 'Produces structured meeting summaries',
    instructions: 'You are a meeting summarizer. Extract key information and format it according to the provided schema.',
    artifacts: [schema.id],
  });

  console.log(agent.id, agent.artifacts);
  ```

  ```go Go theme={null}
  agent, err := client.Agents.CreateAgent(ctx, meibel.CreateAgentDefinitionRequest{
      DisplayName:  "Meeting Summarizer",
      Description:  "Produces structured meeting summaries",
      Instructions: "You are a meeting summarizer. Extract key information and format it according to the provided schema.",
      Artifacts:    []string{schema.ID},
  })
  if err != nil {
      log.Fatal(err)
  }

  fmt.Println(agent.ID, agent.Artifacts)
  ```

  ```bash CLI theme={null}
  meibel agents create --data '{
    "display_name": "Meeting Summarizer",
    "description": "Produces structured meeting summaries",
    "instructions": "You are a meeting summarizer. Extract key information and format it according to the provided schema.",
    "artifacts": ["'"$SCHEMA_ID"'"]
  }'
  ```
</CodeGroup>

When an agent has an artifact schema attached, its responses will include a structured `artifact` field alongside the natural language message. The artifact conforms to the JSON Schema you defined, making it straightforward to parse and store programmatically.
