AgentOp

API Reference

Technical reference for building agents and templates on AgentOp

Overview

This reference covers the configuration formats, template variables, package system, and provider capabilities available when building agents and templates on AgentOp.

Agent Configuration

When creating or editing an agent, you configure the following properties:

Property Description
name Display name for the agent (shown in marketplace and agent detail page)
description Markdown-supported description of agent capabilities
template The base template providing HTML structure, default code, and styling
provider AI backend: openai, anthropic, or local
python_code Custom Python agent logic that runs via Pyodide in the browser
tags Categorization tags for discovery in the marketplace
is_public Whether the agent is listed in the marketplace (default: private)
allow_forks Whether other users can fork and customize this agent

Packages Configuration Format

Python packages for an agent are configured using this JSON structure:

{
  "provider": "openai",        // "openai", "anthropic", or "local"
  "pyodide_builtins": [
    "numpy",
    "pandas",
    "matplotlib"
  ],
  "pypi_packages": {
    "requests": ">=2.28.0",   // minimum version
    "langchain": ">=0.1.0",
    "beautifulsoup4": "*"     // latest available version
  }
}

Template Configuration

Templates define the reusable foundation for agents: HTML/CSS/JS structure, default Python code, prompt defaults, and package requirements.

Property Description
name Unique name for the template
description What kinds of agents this template is designed for
html_code HTML structure with Mustache placeholders like {{agent_name}}
css_code Optional CSS styles injected into the generated agent
js_code Optional JavaScript for client-side interactivity
python_code Default Python code that agents built from this template start with
system_prompt Default system-level LLM instructions
user_prompt_template How user messages are formatted before being sent to the LLM
prompt_variables JSON schema for configurable prompt placeholders
few_shot_examples Example input/output pairs to guide LLM behaviour
conversation_memory_enabled Whether to maintain conversation history across messages
max_memory_messages Maximum number of past messages to retain in memory
default_packages Default Python packages applied to all agents using this template

Prompt Variables Format

Define configurable placeholders in the prompt using this JSON structure:

{
  "domain": {
    "type": "string",
    "default": "general assistance",
    "description": "The agent's area of expertise"
  },
  "tone": {
    "type": "string",
    "default": "professional",
    "options": ["professional", "casual", "formal"]
  }
}

Few-Shot Examples Format

Guide LLM behaviour with example conversations:

[
  {
    "input": "What's the weather in San Francisco?",
    "output": "Let me check that for you. The weather in San Francisco is sunny and 72°F."
  },
  {
    "input": "How about tomorrow?",
    "output": "Tomorrow looks partly cloudy with a high of 68°F."
  }
]

Template Context Variables

These variables are injected into HTML templates when an agent is generated:

Variable Type Description
agent_name string Agent display name
description string Agent description
python_code string Agent Python code
provider string Provider identifier: openai, anthropic, or local
provider_display_name string Human-readable provider name (e.g., "OpenAI", "Anthropic Claude")
pyodide_version string Pyodide runtime version (e.g., "0.29.0")
pyodide_packages list Pyodide built-in package names selected for this agent
pypi_packages dict PyPI packages with their version specifiers
needs_webllm boolean Whether the WebLLM runtime should be loaded (true for local provider)
system_prompt string System prompt passed to the LLM
user_prompt_template string User prompt template

Package Management

AgentOp supports two types of Python packages that run in the browser via Pyodide:

Pyodide Built-in Packages

Pre-compiled packages bundled with the Pyodide distribution:

  • Data Science: numpy, pandas, scipy, scikit-learn
  • Visualization: matplotlib, bokeh, plotly
  • Web: requests, beautifulsoup4, lxml
  • Utilities: pillow, regex, yaml, pytz

Version Locking

Pyodide built-ins use the versions bundled with the Pyodide release. You cannot specify custom versions for these packages. Check the Pyodide package list for all available built-ins.

PyPI Packages

Pure-Python packages installed at runtime from PyPI via micropip:

{
  "pypi_packages": {
    "requests": ">=2.28.0",  // minimum version
    "langchain": ">=0.1.0",
    "python-dotenv": "*"     // latest version
  }
}

Compatibility Requirement

Only pure-Python packages work with Pyodide. Packages with C extensions (except those pre-compiled for Pyodide) will fail to install in the browser.

Version Resolution

When an agent's custom packages conflict with its template's default packages, AgentOp automatically resolves the versions. Compatible version ranges are merged (the more restrictive constraint wins). Incompatible conflicts are reported in the package editor so you can resolve them manually.

HTML Generation

When you download an agent, AgentOp generates a self-contained HTML file on the fly. Nothing is stored on disk — the file is created fresh each time for privacy.

Generation Flow

  1. Load Template: Fetch the HTML, CSS, and JS from the agent's template
  2. Build Context: Collect agent data, packages, and provider config
  3. Render Placeholders: Replace template variables with agent-specific values
  4. Inject Runtime: Add encryption UI (OpenAI/Anthropic) or WebLLM loader (local)
  5. Return File: Serve the complete standalone HTML file for download

Provider Capabilities

Provider Display Name Streaming Tool Calling API Key Required
openai OpenAI Yes Full support via OpenAI API Yes
anthropic Anthropic Claude Yes Full support via Anthropic API Yes
local Local WebLLM Yes Full support via LangChain.js No

Prompt Version Control

Every template supports prompt versioning so you can track changes and roll back if needed.

Creating a Version

  1. Open a template and navigate to the Prompts tab
  2. Edit the system prompt, user prompt template, or few-shot examples
  3. Click Save as New Version
  4. Add an optional description of what changed

Version Fields

Field Description
version_number Auto-incrementing version number (1, 2, 3...)
system_prompt Snapshot of the system prompt at the time of saving
user_prompt_template Snapshot of the user prompt template
few_shot_examples Snapshot of few-shot examples
change_description Optional note describing what changed
is_active Whether this version's prompts are currently applied to the template

Activating a Version

Navigate to the version history page for a template, find the version you want, and click Activate. This applies that version's prompts to the template and marks it as active.

Security

API Key Encryption

AgentOp uses AES-256-GCM encryption with PBKDF2 key derivation (100,000 iterations) to protect API keys. Encryption and decryption happen entirely in the browser — no keys are ever transmitted to or stored on AgentOp servers.

  1. When downloading an API-based agent, you choose an encryption password
  2. Your API key is encrypted client-side before the download is generated
  3. The encrypted key is embedded in the HTML file
  4. When anyone opens the agent, they enter the password to decrypt the key locally

Privacy by Design

Agent HTML files are generated on demand and never saved to disk on the server. Each download is a fresh render. This means your agent code is never stored in a way that could be accessed outside of your account.

Next Steps