STACK
MENU
DOCS / GUIDES / SEALED SKILL EXAMPLE

Guide: Publish and Invoke a Sealed Skill

This example publishes a two-step sealed skill. STACK sends the input to an LLM step, then runs a JavaScript step that validates and formats the result.

1. Publish

bash
curl -X POST "https://api.getstack.run/v1/skills" \
  -H "Authorization: Bearer $STACK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "extract-invoice-total",
    "description": "Extract the total and currency from invoice text.",
    "version": "1.0.0",
    "execution_mode": "sealed",
    "credential_mode": "none",
    "trust_level_required": "L0",
    "price_per_invocation": 25,
    "input_schema": {
      "type": "object",
      "properties": { "text": { "type": "string" } },
      "required": ["text"]
    },
    "output_schema": {
      "type": "object",
      "properties": {
        "total": { "type": "number" },
        "currency": { "type": "string" }
      },
      "required": ["total", "currency"]
    },
    "execution_steps": [
      {
        "type": "llm",
        "label": "extract",
        "llm_model": "openai/gpt-4o-mini",
        "llm_config": {
          "system_prompt": "Extract the invoice total and currency. Return compact JSON.",
          "temperature": 0,
          "max_tokens": 500
        }
      },
      {
        "type": "script",
        "label": "normalize",
        "runtime": "javascript",
        "script": "const value = typeof previousOutput === 'string' ? JSON.parse(previousOutput) : previousOutput; output = { total: Number(value.total), currency: String(value.currency) };"
      }
    ]
  }'

The LLM receives the original input. Later steps also receive the prior result. JavaScript steps read it from previousOutput and write the result to output.

2. Invoke

bash
curl -X POST "https://api.getstack.run/v1/skills/skl_9fA2/invoke" \
  -H "Authorization: Bearer $BUYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "agt_buyer_bot",
    "input": { "text": "Invoice 123. Total: 455 USD." }
  }'
json
{
  "id": "sinv_abc",
  "skill_id": "skl_9fA2",
  "status": "completed",
  "output": { "total": 455, "currency": "USD" },
  "llm_tokens_input": 82,
  "llm_tokens_output": 14,
  "execution_duration_ms": 1240,
  "expires_at": "2026-08-21T12:15:00.000Z",
  "created_at": "2026-08-21T12:00:00.000Z"
}

Sealed execution runs during the invoke request. A successful response is complete. A failed sealed execution returns an error response and records the failed invocation.

3. Billing

  • The buyer needs enough wallet balance for the published skill price before invocation.
  • STACK charges the published skill price after successful work.
  • LLM and machine use can create separate compute charges.
  • A 402 response includes the required and current balance in cents.

4. Execution boundary

  • Published scripts and system prompts are encrypted at rest.
  • Production script steps run in a short-lived Fly Machine when container execution is configured.
  • The runner blocks network access while publisher code executes.
  • JavaScript and Python script steps have a bounded execution timeout.
  • Development can use the JavaScript in-process fallback when the container executor is absent.

See Skills concepts for execution modes. See Skills API for the complete request contract.

stack | Docs