Cookbook
Copy-paste examples for common tasks. Every recipe includes cURL, TypeScript (SDK), Python, and Node.js variants. Replace YOUR_API_KEY with your per-user API key.
Base URL: https://api.lvng.ai/api
Authenticate
All requests need an API key via the Authorization header as a Bearer token. The x-api-key header is also supported.
curl https://api.lvng.ai/api/v2/agents \
-H "Authorization: Bearer YOUR_API_KEY"import { LvngClient } from '@lvng/sdk';
const lvng = new LvngClient({
apiKey: process.env.LVNG_API_KEY
});import os
import requests
BASE = "https://api.lvng.ai/api"
HEADERS = {
"Authorization": f"Bearer {os.environ['LVNG_API_KEY']}",
"Content-Type": "application/json"
}const axios = require('axios');
const api = axios.create({
baseURL: 'https://api.lvng.ai/api',
headers: { 'Authorization': `Bearer ${process.env.LVNG_API_KEY}` }
});List Workflows
Get all workflows in your workspace.
curl https://api.lvng.ai/api/v2/workflows \
-H "Authorization: Bearer YOUR_API_KEY"const { workflows } = await lvng.workflows.list();
console.log(workflows);resp = requests.get(f"{BASE}/v2/workflows", headers=HEADERS)
workflows = resp.json()["data"]
for wf in workflows:
print(f"{wf['name']} — {wf['status']}")const { data } = await api.get('/v2/workflows');
console.log(data.data);Execute a Workflow
Trigger a workflow with input variables and get the run ID.
curl -X POST https://api.lvng.ai/api/v2/workflows/WF_ID/execute \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"inputs": {"topic": "Q4 market analysis"}}'const run = await lvng.workflows.execute('WF_ID', {
inputs: { topic: 'Q4 market analysis' }
});
console.log('Run ID:', run.id);resp = requests.post(
f"{BASE}/v2/workflows/WF_ID/execute",
headers=HEADERS,
json={"inputs": {"topic": "Q4 market analysis"}}
)
run = resp.json()["data"]
print(f"Run ID: {run['id']}")const { data } = await api.post('/v2/workflows/WF_ID/execute', {
inputs: { topic: 'Q4 market analysis' }
});
console.log('Run ID:', data.data.id);Create an Agent
Deploy a new AI agent with a custom system prompt and tools.
curl -X POST https://api.lvng.ai/api/v2/agents \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Research Assistant",
"system_prompt": "You are a helpful research assistant.",
"model": "claude-sonnet-4-6",
"tools": ["web_search", "knowledge_search"]
}'const agent = await lvng.agents.create({
name: 'Research Assistant',
systemPrompt: 'You are a helpful research assistant.',
model: 'claude-sonnet-4-6',
tools: ['web_search', 'knowledge_search']
});
console.log('Agent ID:', agent.id);resp = requests.post(f"{BASE}/v2/agents", headers=HEADERS, json={
"name": "Research Assistant",
"system_prompt": "You are a helpful research assistant.",
"model": "claude-sonnet-4-6",
"tools": ["web_search", "knowledge_search"]
})
agent = resp.json()["data"]
print(f"Agent ID: {agent['id']}")Message an Agent
Send a message to a running agent and get a response.
curl -X POST https://api.lvng.ai/api/v2/agents/AGENT_ID/message \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "What are the top trends in AI for 2026?"}'const response = await lvng.agents.message('AGENT_ID', {
message: 'What are the top trends in AI for 2026?'
});
console.log(response.content);resp = requests.post(
f"{BASE}/v2/agents/AGENT_ID/message",
headers=HEADERS,
json={"message": "What are the top trends in AI for 2026?"}
)
print(resp.json()["data"]["content"])Search Knowledge
Semantic search across your ingested knowledge graph.
curl -X POST https://api.lvng.ai/api/knowledge/search \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "revenue trends Q4", "limit": 10}'const results = await lvng.knowledge.search({
query: 'revenue trends Q4',
limit: 10
});
results.forEach(r => console.log(r.title, r.score));resp = requests.post(f"{BASE}/knowledge/search", headers=HEADERS, json={
"query": "revenue trends Q4",
"limit": 10
})
for result in resp.json()["data"]:
print(f"{result['title']} — score: {result['score']}")Chat with AI
Send a message to the AI and get a response.
curl -X POST https://api.lvng.ai/api/v2/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Summarize the latest market research",
"channelId": "CHANNEL_ID"
}'resp = requests.post(f"{BASE}/v2/chat", headers=HEADERS, json={
"message": "Summarize the latest market research",
"channelId": "CHANNEL_ID"
})
print(resp.json()["data"]["content"])Stream Chat (SSE)
Stream AI responses in real-time using Server-Sent Events.
curl -N -X POST https://api.lvng.ai/api/v2/chat/stream \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Write a 3-paragraph market analysis"}'const response = await fetch('https://api.lvng.ai/api/v2/chat/stream', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.LVNG_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ message: 'Write a 3-paragraph analysis' })
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
process.stdout.write(chunk);
}import sseclient
import requests
resp = requests.post(
f"{BASE}/v2/chat/stream",
headers=HEADERS,
json={"message": "Write a 3-paragraph analysis"},
stream=True
)
client = sseclient.SSEClient(resp)
for event in client.events():
print(event.data, end="", flush=True)Send a Channel Message
Post a message to a workspace channel.
curl -X POST https://api.lvng.ai/api/v2/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel_id": "CHANNEL_ID",
"content": "Hello from the API!"
}'resp = requests.post(f"{BASE}/v2/messages", headers=HEADERS, json={
"channel_id": "CHANNEL_ID",
"content": "Hello from the API!"
})
msg = resp.json()["data"]
print(f"Message ID: {msg['id']}")const { data } = await api.post('/v2/messages', {
channel_id: 'CHANNEL_ID',
content: 'Hello from the API!'
});
console.log('Message ID:', data.data.id);Generate & Revoke API Keys
Programmatically manage API keys (requires JWT auth, not API key auth).
# Create a key
curl -X POST https://api.lvng.ai/api/v2/api-keys \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "ci-pipeline", "scopes": ["read", "execute"]}'
# List keys
curl https://api.lvng.ai/api/v2/api-keys \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
# Revoke a key
curl -X DELETE https://api.lvng.ai/api/v2/api-keys/KEY_ID \
-H "Authorization: Bearer YOUR_JWT_TOKEN"# Create
resp = requests.post(f"{BASE}/v2/api-keys",
headers={"Authorization": f"Bearer {jwt_token}", "Content-Type": "application/json"},
json={"name": "ci-pipeline", "scopes": ["read", "execute"]}
)
new_key = resp.json()["data"]["key"]
print(f"New key: {new_key}") # Save this — shown once!
# Revoke
requests.delete(f"{BASE}/v2/api-keys/{key_id}",
headers={"Authorization": f"Bearer {jwt_token}"}
)Create a Digital Twin
Add an AI persona to your workspace.
curl -X POST https://api.lvng.ai/api/v2/twins \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Marketing Expert",
"personality": "creative, data-driven, concise",
"system_prompt": "You are a senior marketing strategist with 15 years of experience."
}'resp = requests.post(f"{BASE}/v2/twins", headers=HEADERS, json={
"name": "Marketing Expert",
"personality": "creative, data-driven, concise",
"system_prompt": "You are a senior marketing strategist with 15 years of experience."
})
twin = resp.json()["data"]
print(f"Twin ID: {twin['id']}")Full Cookbook on GitHub
Browse the complete cookbook with runnable scripts, CI/CD templates, and integration patterns.
LVNG-AI/cookbook