SDK Reference
Python and TypeScript SDKs for the LyDos API — currently in Beta.
Rate Limits
| Plan | Requests / min | Requests / day | Concurrent tasks |
|---|---|---|---|
| Alpha (Free) | 60 RPM | 600 / day | 5 |
Python SDK
lydos CLI directly. A pip-installable package is being prepared.Installation
# Python SDK — Beta (not yet published to PyPI) # Install from source during beta: git clone https://github.com/lydianai/AILYDIAN-AGENT-ORCHESTRATOR.git cd AILYDIAN-AGENT-ORCHESTRATOR && pip install -r requirements.txt # Or use the REST API directly: curl http://localhost:8888/api/health
Initialization
from lydos import LydosClient
client = LydosClient(
token="lyd_sk_your_token_here", # Optional: uses LYDOS_TOKEN env var
base_url="https://lydos.ailydian.com", # Optional: defaults to public API
timeout=30.0, # Optional: request timeout in seconds
)Chat Methods
chat.create(messages, **kwargs) → ChatResponse
Send a conversation and get a response.
response = client.chat.create(
messages=[
{"role": "user", "content": "Explain quantum computing"}
],
model="llama-3.3-70b-versatile", # optional
max_tokens=512, # optional
temperature=0.7 # optional
)
print(response.text) # str: The generated response
print(response.model) # str: Model used
print(response.tokens_used) # int: Token count
print(response.latency_ms) # int: Milliseconds to generatechat.stream(messages, **kwargs) → Generator[ChatStreamChunk]
Stream response tokens in real-time.
for chunk in client.chat.stream(
messages=[{"role": "user", "content": "Write a poem about AI"}]
):
print(chunk.delta, end="", flush=True) # str: Token delta
# chunk.done == True on last chunkAgent Methods
agents.list() → List[AgentInfo]
List all 109 available agents.
agents = client.agents.list()
for agent in agents:
print(f"{agent.id}: {agent.description}")
print(f" Category: {agent.category}")
print(f" Parameters: {agent.parameters}")agents.run(agent_type: str, prompt: str, params: dict) → RunAgentResponse
Execute an agent with a task prompt.
result = client.agents.run(
"harika",
prompt="Analyze security posture of this codebase",
params={"depth": "comprehensive", "include_deps": True}
)
print(result.task_id) # str: ID for polling
print(result.status) # str: Current statusMemory Methods
The memory API persists key-value data and supports semantic search across stored entries.
# Store a value
client.memory.store("project_context", {
"name": "my-app",
"stack": "Next.js + FastAPI",
"last_review": "2026-03-27"
})
# Retrieve by key
ctx = client.memory.get("project_context")
print(ctx) # dict: stored value
# Semantic search across all stored entries
results = client.memory.search("project stack technology")
for item in results:
print(f"{item.key}: {item.score:.2f} — {item.preview}")Async Support
Use AsyncLydosClient for async/await workflows. All methods mirror the synchronous client.
import asyncio
from lydos import AsyncLydosClient
async def main() -> None:
async with AsyncLydosClient(token="lyd_sk_...") as client:
response = await client.chat.create(
messages=[{"role": "user", "content": "Hello"}]
)
print(response.text)
result = await client.agents.run(
"harika",
prompt="Scan ./src for security issues"
)
print(result.task_id)
asyncio.run(main())Task Methods
tasks.list(status: str = None) → List[TaskInfo]
List tasks with optional status filter.
# List running tasks tasks = client.tasks.list(status="running") # List all tasks all_tasks = client.tasks.list()
tasks.get(id: str) → TaskInfo
Get full task details including result.
task = client.tasks.get("task_3f8c9d2e1b4a5e7f")
print(task.status) # str: running | completed | failed
print(task.result) # str: Final result (when completed)
print(task.elapsed_seconds) # int: Execution timetasks.cancel(id: str) → None
Cancel a running or pending task.
client.tasks.cancel("task_3f8c9d2e1b4a5e7f")System Methods
health() → HealthResponse
Get system health and metrics.
health = client.health() print(health.score) # int: 0-100 print(health.status) # str: operational | degraded | outage print(health.engines_active) # int: Number of active Q-engines print(health.agents_available) # int: Number of available agents
engines.list() → List[EngineInfo]
List all Q-engines (Q1–Q248) with details.
engines = client.engines.list()
for engine in engines:
print(f"{engine.id}: {engine.name}")Error Handling
All exceptions inherit from LydosError. Catch specific subclasses for granular handling:
from lydos import LydosClient, LydosError, LydosAuthError, LydosRateLimitError
client = LydosClient(token="lyd_sk_...")
try:
response = client.chat.create(
messages=[{"role": "user", "content": "Hello"}]
)
except LydosAuthError:
# Token is invalid or has been revoked
print("Invalid token — run: lydos login")
except LydosRateLimitError as e:
# HTTP 429 — back off and retry
print(f"Rate limit hit. Retry after {e.retry_after}s")
except LydosError as e:
# Catch-all for any other API or network error
print(f"LyDos error: {e.status_code} — {e.message}")TypeScript SDK
Beta
The TypeScript SDK is in Beta — the API surface below is stable but the npm package is not yet published. Use the REST API or the Python SDK for production workloads while the package is being prepared.
Installation
# Beta — npm package coming soon # Use the REST API or SDK source directly: curl https://lydos.ailydian.com/api/health
Initialization
import { LydosClient } from '@lydos/sdk';
const client = new LydosClient({
token: process.env.LYDOS_TOKEN, // Optional: uses LYDOS_TOKEN env var
baseUrl: 'https://lydos.ailydian.com', // Optional: custom API URL
timeout: 30_000, // Optional: timeout in milliseconds
});Chat Methods
chat.create(options): Promise<ChatResponse>
Send a conversation and get a response.
const response = await client.chat.create({
messages: [{ role: 'user', content: 'Explain async/await' }],
model: 'llama-3.3-70b-versatile', // optional
maxTokens: 512, // optional
});
console.log(response.text); // Response text
console.log(response.model); // Model name
console.log(response.tokensUsed); // Token count
console.log(response.latencyMs); // Latency in mschat.stream(options): AsyncGenerator<ChatStreamChunk>
Stream response tokens.
for await (const chunk of client.chat.stream({
messages: [{ role: 'user', content: 'Write a poem' }],
})) {
process.stdout.write(chunk.delta);
}Agents, Memory & Tasks
// Agents
const agents = await client.agents.list();
const result = await client.agents.run('harika', {
prompt: 'Analyze security posture of ./src',
params: { depth: 'comprehensive' }
});
// Memory
await client.memory.store('project_context', { stack: 'Next.js' });
const ctx = await client.memory.get('project_context');
const hits = await client.memory.search('project technology stack');
// Tasks
const tasks = await client.tasks.list({ status: 'running' });
const task = await client.tasks.get('task_id');
await client.tasks.cancel('task_id');
// Health & Engines
const health = await client.health();
const engines = await client.engines.list();Error Handling (TypeScript)
import {
LydosClient,
LydosAuthError,
LydosRateLimitError,
LydosError,
} from '@lydos/sdk';
const client = new LydosClient({ token: process.env.LYDOS_TOKEN });
try {
const response = await client.chat.create({
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(response.text);
} catch (err) {
if (err instanceof LydosAuthError) {
console.error('Invalid token — run: lydos login');
} else if (err instanceof LydosRateLimitError) {
console.error(`Rate limited. Retry after ${err.retryAfter}s`);
} else if (err instanceof LydosError) {
console.error(`API error ${err.statusCode}: ${err.message}`);
} else {
throw err;
}
}WebSocket Events
Connect to the real-time event stream for live health, task, and metrics updates:
import { LydosWebSocket } from '@lydos/sdk';
const ws = new LydosWebSocket({
url: 'wss://lydos.ailydian.com/v1/stream',
token: process.env.LYDOS_TOKEN!,
});
ws.on('health', (data) => {
console.log(`Health: ${data.score}/100`);
});
ws.on('task_update', (data) => {
console.log(`Task ${data.taskId}: ${data.status}`);
});
ws.on('metrics', (data) => {
console.log(`Active agents: ${data.agentsActive}`);
});
ws.connect();
// Cleanup
ws.disconnect();Environment Variables
LYDOS_TOKENYour API token (written by lydos login)LYDOS_API_URLCustom API URL (defaults to https://lydos.ailydian.com)LYDOS_TIMEOUTRequest timeout in seconds (default: 30)Need Help?
Check our resources or ask the community:
- Getting Started for quick setup guide
- API Reference for endpoint docs
- CLI Reference for command documentation