Skip to main content
The Prompts API lets you store, version, and manage prompt templates centrally. Every template change creates an immutable version, giving you a full change history with the ability to roll back to any previous version at any time. Templates support {{variable}} placeholders that are rendered server-side when you retrieve a prompt, so you can reuse the same template across different contexts.

Create a prompt

Create a prompt with a name and template. The first version is created automatically.
mka1 llm prompts create \
  --body '{
    "name": "greeting",
    "description": "A simple greeting template",
    "template": "Hello, {{name}}! Welcome to {{company}}.",
    "metadata": { "team": "onboarding" }
  }' \
  -H 'X-On-Behalf-Of: <end-user-id>'

Retrieve a prompt with rendered variables

Pass variables as a query parameter to render the template with your values. Unmatched placeholders are left as-is.
mka1 llm prompts get \
  --id prompt_abc123 \
  --variables '{"name":"Alice","company":"Acme"}'

List prompts

Retrieve a paginated list of all prompts. Use after for cursor-based pagination.
mka1 llm prompts list --limit 10 --order desc

Update prompt metadata

Update the name, description, or metadata of a prompt. To change the template, create a new version instead.
mka1 llm prompts update \
  --id prompt_abc123 \
  --body '{
    "name": "welcome-greeting",
    "description": "Updated greeting for the welcome flow",
    "metadata": { "team": "onboarding", "reviewed": true }
  }'

Create a new version

Each template change creates a new version. The new version automatically becomes the active version.
mka1 llm prompts create-version \
  --id prompt_abc123 \
  --body '{
    "template": "Hi {{name}}! Welcome aboard at {{company}}. Your onboarding starts {{date}}."
  }'

View version history

List all versions of a prompt to see its full change history.
mka1 llm prompts list-versions --id prompt_abc123 --order desc

Retrieve a specific version

Fetch a single version by its version number.
mka1 llm prompts get-version --id prompt_abc123 --version-param 1

Roll back to a previous version

Rollback sets an earlier version as the active version. All versions are preserved — rollback does not delete newer versions, so you can always roll forward again.
# Currently on version 2, roll back to version 1
mka1 llm prompts rollback --id prompt_abc123 --version-param 1

Delete a prompt

Deleting a prompt removes it and all of its versions permanently.
mka1 llm prompts delete --id prompt_abc123

Full example: versioning and rollback workflow

This example demonstrates the complete lifecycle — creating a prompt, iterating on the template, reviewing history, and rolling back.
# 1. Create a prompt with the initial template
mka1 llm prompts create \
  --body '{
    "name": "support-reply",
    "template": "Hi {{customer}}, thanks for contacting us about {{issue}}."
  }'
# → { "id": "prompt_abc123", "active_version": 1, ... }

# 2. Ship v2 with a friendlier tone
mka1 llm prompts create-version \
  --id prompt_abc123 \
  --body '{
    "template": "Hey {{customer}}! We got your message about {{issue}} and are on it."
  }'

# 3. Retrieve the prompt with rendered variables
mka1 llm prompts get \
  --id prompt_abc123 \
  --variables '{"customer":"Alice","issue":"billing"}'

# 4. Review version history
mka1 llm prompts list-versions --id prompt_abc123 --order asc

# 5. Roll back to v1
mka1 llm prompts rollback --id prompt_abc123 --version-param 1

# 6. Clean up
mka1 llm prompts delete --id prompt_abc123

Behavior details

AspectDetail
VersioningImmutable — each template change creates a new version that cannot be modified
Active versionNew versions auto-activate; use rollback to switch to a different version
RollbackNon-destructive — sets active_version without deleting newer versions
PaginationCursor-based for listing prompts — use after parameter with first_id/last_id from response
Template renderingServer-side — pass variables query parameter; unmatched placeholders preserved
OwnershipPer API key — prompts are isolated by authentication context
ConcurrencyConflict detection — concurrent version creation returns 409

Next steps