LightStruc Universal Agentic SDK
A multi-language client library and standardized agentic execution engine. Connect directly to LightStruc's autonomous multi-agent mesh, orchestrated DAG pipelines, unified model discovery, and streaming conversational sessions with zero third-party package dependencies.
Installation & Setup
Each LightStruc SDK is crafted to be completely self-contained. You do not need to download hundreds of megabytes of third-party registry packages. Simply download the standalone zip archive or extract it into your project folder.
Extract the downloaded lightstruc-sdk-node.zip into your application. Supports both CommonJS and Modern ES Modules natively with pure Node.js standard libraries.
// CommonJS
const { LightStrucClient } = require('./sdk/dist/index.js');
// Or ES Modules
import { LightStrucClient } from './sdk/dist/index.mjs';
const client = new LightStrucClient({
apiKey: process.env.LSAI_API_KEY || 'lsai_sk_live_...',
projectId: 'billing-app',
endpoint: 'http://localhost:8080' // Or your staging/production host
});
Unpack lightstruc-sdk-python.zip into your project or install locally with pip install -e .. Built entirely on Python standard libraries (urllib, json, asyncio).
from lightstruc import LightStrucClient
client = LightStrucClient(
api_key="lsai_sk_live_...",
project_id="analytics-team",
endpoint="http://localhost:8080"
)
Extract lightstruc-sdk-csharp.zip and reference the pre-compiled LightStruc.Sdk.dll or add the LightStruc.Sdk.csproj directly into your solution. No NuGet dependencies required.
using System;
using LightStruc.Sdk;
var client = new LightStrucClient(new ClientOptions
{
ApiKey = "lsai_sk_live_...",
ProjectId = "dotnet-backend",
Endpoint = "http://localhost:8080"
});
Extract lightstruc-sdk-cpp.zip and include the header-only directory in your CMake configuration or compiler flags. Standard C++17 compatible.
#include "lightstruc/client.hpp"
lightstruc::ClientOptions options;
options.api_key = "lsai_sk_live_...";
options.project_id = "embedded-core";
options.endpoint = "http://localhost:8080";
lightstruc::Client client(options);
Authentication & Scopes
All SDK requests authenticate using an Account Access Key generated from the Access Keys Portal. Keys follow the standardized format lsai_sk_live_....
Pass your key via the Authorization: Bearer <key> header or the X-API-Key: <key> header. The SDK client automatically includes both headers on every outgoing call.
| Scope Name | Description | Target Capabilities |
|---|---|---|
sdk |
Master SDK Scope | Full administrative and operational access to all SDK v1 endpoints. |
models |
Model Discovery | Enumerate, inspect, and configure AI model endpoints and providers. |
agents |
Autonomous Agents | Invoke agents, stream thoughts, execute actions, and query agent metadata. |
workflows |
DAG Workflows | Author, compile, validate, and execute complex multi-agent workflows. |
sessions |
Conversational Sessions | Create persistent multi-turn conversational sessions and stream turns. |
Models API
Inspect available LLM providers, active routing configurations, and register custom model endpoints.
// List all registered models
const models = await client.models.list();
console.log('Available models:', models);
// Get specific model details
const model = await client.models.get('gpt-4o');
console.log('Model specifications:', model);
# List available models
models = client.models.list()
print("Registered Models:", models)
# Inspect model details
info = client.models.get("claude-3-5-sonnet")
print("Model details:", info)
// List models
var models = await client.Models.ListAsync();
Console.WriteLine($"Models loaded: {models.Count}");
// Inspect specific model
var model = await client.Models.GetAsync("gpt-4o");
Console.WriteLine($"Model provider: {model.Provider}");
// List models
auto models = client.models().list();
std::cout << "Models: " << models.dump() << std::endl;
// Get model details
auto model = client.models().get("gemini-1.5-pro");
std::cout << "Model: " << model.dump() << std::endl;
Agents & Live Streaming
Invoke autonomous agents to solve complex multi-step objectives. The SDK supports both synchronous completion and real-time Server-Sent Events (SSE) streaming of thinking tokens, tool executions, and final deliverables.
// Synchronous agent invocation
const result = await client.agents.invoke('code-auditor', {
prompt: 'Review the payment gateway retry logic for idempotency vulnerabilities.',
stream: false
});
console.log('Audit Summary:', result.response);
// Real-time live turn streaming with Server-Sent Events
await client.agents.stream('code-auditor', {
prompt: 'Audit auth middleware implementation.',
onChunk: (event) => {
if (event.type === 'thought') {
console.log('[Thinking]:', event.content);
} else if (event.type === 'token') {
process.stdout.write(event.content);
}
}
});
# Synchronous invoke
res = client.agents.invoke("data-engineer", {
"prompt": "Optimize our PostgreSQL query execution plan for 10M rows.",
"stream": False
})
print("Agent Deliverable:", res.get("response"))
# Streaming turn generator
for chunk in client.agents.stream("data-engineer", prompt="Generate SQL migration"):
if chunk.get("type") == "token":
print(chunk.get("content"), end="", flush=True)
// Synchronous invocation
var response = await client.Agents.InvokeAsync("cloud-architect", new {
prompt = "Design a multi-region failover topology with low latency.",
stream = false
});
Console.WriteLine(response.Response);
// Asynchronous SSE streaming
await foreach (var evt in client.Agents.StreamAsync("cloud-architect", "Design topology"))
{
Console.Write(evt.Content);
}
lightstruc::Json payload;
payload["prompt"] = "Synthesize an executive summary of system architecture.";
payload["stream"] = false;
auto result = client.agents().invoke("default-assistant", payload);
std::cout << result.dump() << std::endl;
Workflows & DAG Pipelines
Construct multi-agent pipelines using the fluent Workflow DAG Builder. Nodes represent autonomous agent tasks, and edges define dependencies and data passing.
const { WorkflowBuilder } = require('./sdk/dist/index.js');
// 1. Build the DAG pipeline
const workflow = new WorkflowBuilder('ReleasePipeline')
.addNode('lint', 'code-linter', { strict: true })
.addNode('security', 'security-auditor', { scanLevel: 'deep' })
.addNode('deploy', 'cloud-deployer', { environment: 'staging' })
.connect('lint', 'security')
.connect('security', 'deploy')
.build();
// 2. Register and trigger execution
const created = await client.workflows.create(workflow);
const run = await client.workflows.run(created.id, { releaseTag: 'v2.1.114' });
console.log('Pipeline Run ID:', run.runId);
from lightstruc import WorkflowBuilder
# Construct declarative pipeline DAG
builder = WorkflowBuilder("ECommercePipeline")
builder.add_node("enrichment", "product-enricher", {"category": "electronics"})
builder.add_node("pricing", "dynamic-pricer", {"margin": 0.25})
builder.connect("enrichment", "pricing")
dsl = builder.build()
# Create and execute
wf = client.workflows.create(dsl)
execution = client.workflows.run(wf["id"], inputs={"batch_id": "batch_9812"})
print("Execution Result:", execution)
var builder = new WorkflowBuilder("DataIngestionWorkflow");
builder.AddNode("extract", "crawler-agent", new { target = "https://example.com" });
builder.AddNode("transform", "etl-agent", new { format = "parquet" });
builder.Connect("extract", "transform");
var dsl = builder.Build();
var workflow = await client.Workflows.CreateAsync(dsl);
var run = await client.Workflows.RunAsync(workflow.Id, new { batchId = "batch_001" });
Console.WriteLine($"Workflow status: {run.Status}");
lightstruc::WorkflowBuilder builder("CompilePipeline");
builder.add_node("step_build", "builder-agent", {{"target", "x86_64"}});
builder.add_node("step_test", "tester-agent", {{"filter", "*unit*"}});
builder.connect("step_build", "step_test");
auto dsl = builder.build();
auto response = client.workflows().create(dsl);
std::cout << "Workflow Created: " << response.dump() << std::endl;
Conversational Sessions
Maintain stateful conversational context across multiple turns. The session maintains historical memory, human-in-the-loop decisions, and intermediate tool broker calls.
// Create a stateful session
const session = await client.sessions.create({
agentId: 'default-assistant',
title: 'Customer Onboarding Chat'
});
// Send multi-turn messages
const turn1 = await client.sessions.sendTurn(session.id, {
message: 'Hello, what features do you support for team billing?'
});
console.log('Assistant:', turn1.reply);
const turn2 = await client.sessions.sendTurn(session.id, {
message: 'Can you generate an invoice breakdown for 10 seats?'
});
console.log('Assistant:', turn2.reply);
# Start multi-turn conversational session
sess = client.sessions.create(agent_id="research-assistant", title="Deep Market Analysis")
session_id = sess["id"]
# Send turns
t1 = client.sessions.send_turn(session_id, "What are the top 3 AI workflow orchestrators?")
print(t1.get("reply"))
t2 = client.sessions.send_turn(session_id, "Compare their pricing and self-hosted capabilities.")
print(t2.get("reply"))
var session = await client.Sessions.CreateAsync("developer-copilot", "Refactoring Session");
var turn1 = await client.Sessions.SendTurnAsync(session.Id, "Identify bottlenecks in our async event bus.");
Console.WriteLine(turn1.Reply);
var turn2 = await client.Sessions.SendTurnAsync(session.Id, "Produce a refactored implementation in C#.");
Console.WriteLine(turn2.Reply);
lightstruc::Json sessionReq;
sessionReq["agentId"] = "support-agent";
sessionReq["title"] = "Embedded C++ Diagnostics";
auto session = client.sessions().create(sessionReq);
std::string sessionId = session["id"].as_string();
lightstruc::Json turnReq;
turnReq["message"] = "Analyze memory consumption trace.";
auto turn = client.sessions().send_turn(sessionId, turnReq);
std::cout << turn["reply"].as_string() << std::endl;
Standardized REST API Reference
All SDK operations map directly to the standardized LightStruc Core API (/api/sdk/v1/*).
| Method | Endpoint Route | Required Scope | Description |
|---|---|---|---|
| GET | /download/sdk |
Public | Download the self-contained SDK archive (?lang=node|python|csharp|cpp). |
| GET | /api/sdk/v1/models |
models |
Enumerate active and configured AI model backends. |
| GET | /api/sdk/v1/agents |
agents |
List registered agents with capabilities and tool configurations. |
| POST | /api/sdk/v1/agents/:id/invoke |
agents |
Invoke an autonomous agent with optional SSE streaming (stream: true). |
| GET | /api/sdk/v1/workflows |
workflows |
Query saved multi-agent workflow DAG specifications. |
| POST | /api/sdk/v1/workflows |
workflows |
Validate and store a compiled workflow DAG definition. |
| POST | /api/sdk/v1/workflows/:id/run |
workflows |
Trigger workflow execution with payload inputs. |
| POST | /api/sdk/v1/sessions |
sessions |
Initialize a stateful conversational session. |
| POST | /api/sdk/v1/sessions/:id/turn |
sessions |
Execute conversational turn with full context retention and SSE streaming. |
Rate Limits & Quotas
Every LightStruc API key has a configured Requests Per Minute (RPM) limit. Default rate limits:
- Standard Developer Key: 120 RPM
- Production Key: Up to 1,200 RPM
- Custom Enterprise: Negotiated unlimited burst capacity
The server includes rate limit telemetry in response headers:
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 114
X-RateLimit-Reset: 1729184520
Status Codes & Error Handling
Standard HTTP status codes are returned alongside structured JSON error bodies:
| Code | Meaning | Description |
|---|---|---|
200 OK |
Success | Request succeeded and output payload returned. |
400 Bad Request |
Invalid Payload | Missing required parameters or malformed JSON structure. |
401 Unauthorized |
Invalid Key | API key is missing, expired, or invalid. |
403 Forbidden |
Insufficient Scope | Key does not possess the required capability scope (e.g. workflows). |
429 Too Many Requests |
Rate Limit Exceeded | The RPM threshold has been temporarily exceeded. Back off and retry. |
500 Server Error |
Internal Failure | Underlying model provider error or unhandled runtime failure. |