Getting Started with OpenVerb

Learn how to integrate OpenVerb into your app in under 5 minutes. Use your own API keys, your own models, and your own logic.

Installation

JavaScript/TypeScript (npm)

npm install openverb

Or clone from GitHub and import locally:

git clone https://github.com/sgthancel/openverb.git

Python (pip)

pip install openverb

Or clone from GitHub and import locally:

git clone https://github.com/sgthancel/openverb.git

Quick Start Guide

1

Load the Verb Library

Load the OpenVerb core library. It ships inside both packages, or you can pass your own library as a JSON object or string:

// JavaScript (ES modules)
import { createRequire } from 'node:module';
import { loadLibrary } from 'openverb';

const require = createRequire(import.meta.url);
const library = loadLibrary(require('openverb/openverb.core.json'));
console.log(library.namespace); // "openverb.core"
# Python
from openverb import load_core_library

library = load_core_library()
print(library['namespace'])  # "openverb.core"
2

Create an Executor

Register a handler for each verb that maps to your app's actual logic. A handler receives the action's params and returns a result with a status:

// JavaScript
import { createExecutor } from 'openverb';

const executor = createExecutor(library);

executor.register('create_item', async ({ collection, data }) => {
  // Your actual app logic here
  const id = await db[collection].insert(data);
  return { verb: 'create_item', status: 'success', data: { id, ...data } };
});

executor.register('list_items', async ({ collection }) => {
  const items = await db[collection].findAll();
  return { verb: 'list_items', status: 'success', data: { items } };
});
# Python
from openverb import create_executor

executor = create_executor(library)

def create_item(params):
    # Your actual app logic here
    item_id = db[params['collection']].insert(params['data'])
    return {'verb': 'create_item', 'status': 'success',
            'data': {'id': item_id, **params['data']}}

def list_items(params):
    items = db[params['collection']].find_all()
    return {'verb': 'list_items', 'status': 'success', 'data': {'items': items}}

executor.register('create_item', create_item)
executor.register('list_items', list_items)
3

Connect Your Own LLM

Use your own API key with OpenAI, Anthropic, or any LLM provider. The simplest pattern works with any model that can write text: describe the verbs in the system prompt and ask for a JSON action back.

// JavaScript (OpenAI example)
import OpenAI from 'openai';

const openai = new OpenAI(); // reads OPENAI_API_KEY

const response = await openai.chat.completions.create({
  model: process.env.OPENAI_MODEL, // any current chat model
  messages: [
    {
      role: 'system',
      content: `You may perform actions using these OpenVerb verbs:
${JSON.stringify(library.verbs, null, 2)}

To perform an action, reply with only a JSON object:
{"verb": "<verb name>", "params": { ... }}`
    },
    {
      role: 'user',
      content: 'Create a new project for Smith Construction'
    }
  ]
});

Prefer the provider's native tool calling? See Using OpenVerb with OpenAI and Anthropic, which turns each verb into a tool definition.

🔐 Your API key stays on your side. OpenVerb never touches your LLM or data.

4

Parse and Execute Actions

Parse the action from the AI response and hand it to the executor. The executor checks the verb exists and its required params are present before your handler runs:

// JavaScript
const aiOutput = response.choices[0].message.content;
// {"verb":"create_item","params":{"collection":"projects","data":{"client":"Smith Construction"}}}

const action = JSON.parse(aiOutput);
const result = await executor.execute(action);
console.log(result);
// { verb: 'create_item', status: 'success', data: { id: '123', client: 'Smith Construction' } }

// Invalid actions come back as errors instead of reaching your code:
// { verb: 'create_item', status: 'error', error_message: 'Missing required param: data' }

Complete Working Example

Here's a full end-to-end example showing natural language → verb action → app update:

import { createRequire } from 'node:module';
import OpenAI from 'openai';
import { loadLibrary, createExecutor } from 'openverb';

// 1. Load verbs
const require = createRequire(import.meta.url);
const library = loadLibrary(require('openverb/openverb.core.json'));

// 2. Create executor and register handlers
const executor = createExecutor(library);
const db = { projects: [] };

executor.register('create_item', ({ collection, data }) => {
  db[collection] ??= [];
  const item = { id: String(db[collection].length), ...data };
  db[collection].push(item);
  return { verb: 'create_item', status: 'success', data: item };
});

// 3. Setup AI
const openai = new OpenAI(); // reads OPENAI_API_KEY

// 4. User input
const userInput = 'Create a new project for Smith Construction';

// 5. Get AI response
const response = await openai.chat.completions.create({
  model: process.env.OPENAI_MODEL,
  messages: [
    {
      role: 'system',
      content: `You can perform OpenVerb actions. Available verbs: ${JSON.stringify(library.verbs)}
To perform one, reply with only {"verb": "<name>", "params": {...}}`
    },
    { role: 'user', content: userInput }
  ]
});

// 6. Parse and execute
const action = JSON.parse(response.choices[0].message.content);
const result = await executor.execute(action);

console.log('Result:', result);
// { verb: 'create_item', status: 'success', data: { id: '0', client: 'Smith Construction' } }

console.log('Database:', db.projects);
// [{ id: '0', client: 'Smith Construction' }]

Supported Models

OpenVerb works with any LLM that can read and write text. Bring your own API key:

OpenAI

Any GPT chat model, with or without native tool calling

Anthropic

Claude Opus, Sonnet and Haiku, with or without tool use

Google

Gemini models

Local Models

Llama, Mistral, any REST API

Clone the Example Project

OpenVerb Demo App

A complete working example with a simple task manager that responds to natural language commands.

git clone https://github.com/sgthancel/openverb.git
cd openverb/examples/js-executor
npm install
npm start
View Examples on GitHub

Next Steps

Read the Spec

Deep dive into the OpenVerb specification and verb library format.

View Spec

Explore Core Library

Browse all available verbs in the core library.

View Library

Join the Community

Get help, share projects, and contribute to OpenVerb.

GitHub Discussions

Ready to build with OpenVerb?

Start integrating AI actions into your app today. It's free, open, and framework-agnostic.

OpenVerb Sandbox

Paste a Verb Library JSON schema here to define what actions the AI can perform.

Ask the AI to perform a task. It will use the vocabulary defined in your library.

The AI proposes a structured action based on your library vocabulary.

Waiting for prompt...

OpenVerb Core intercepts the AI's action and validates it before execution.

Verb exists in library
Payload matches JSON Schema
Policy requirements passed
Inputs valid and sanitized

The validated action is routed to the application backend for execution.

Waiting...

OpenVerb Core generates an execution receipt for full auditability.

Waiting for execution...