Cookbook
Copy-paste examples for common tasks, in cURL and Python, and in Node.js where it helps. They use plain HTTP, so they work without an SDK. 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 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"resp = requests.get(f"{BASE}/v2/workflows", headers=HEADERS)
for wf in resp.json()["workflows"]:
print(wf["id"], wf["name"])const { data } = await api.get('/v2/workflows');
console.log(data.workflows);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"}}'resp = requests.post(
f"{BASE}/v2/workflows/WF_ID/execute",
headers=HEADERS,
json={"inputs": {"topic": "Q4 market analysis"}}
)
run = resp.json()["run"]
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.run.id);Create an Agent
Create an agent with its own instructions and the tools it may use.
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",
"systemPrompt": "You are a helpful research assistant.",
"capabilities": { "tools": ["web_search", "search_knowledge"] }
}'resp = requests.post(f"{BASE}/v2/agents", headers=HEADERS, json={
"name": "Research Assistant",
"systemPrompt": "You are a helpful research assistant.",
"capabilities": {"tools": ["web_search", "search_knowledge"]}
})
agent = resp.json()["agent"]
print(f"Agent ID: {agent['id']}")Message an Agent
Send a message to an agent and get its answer.
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?"}'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()["response"])Search Knowledge
Find passages that contain your query in the documents you uploaded.
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}'resp = requests.post(f"{BASE}/knowledge/search", headers=HEADERS, json={
"query": "revenue trends Q4",
"limit": 10
})
for hit in resp.json()["results"]:
print(hit["document"]["fileName"], "-", hit["chunk"]["text"][:80])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()["reply"])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 json
import sseclient # pip install sseclient-py
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():
if event.event == "text_delta":
print(json.loads(event.data)["content"], 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 it now: it is shown only once
# Revoke
requests.delete(f"{BASE}/v2/api-keys/{key_id}",
headers={"Authorization": f"Bearer {jwt_token}"}
)