Integrate Alfred into your application in minutes. Official, type-safe client libraries for Node.js, Python, and PHP.
import { AlfredClient } from '@alfredai/sdk';
const alfred = new AlfredClient({ apiKey: 'ak_live_xxx_yyy' });
// Execute a tool
const result = await alfred.tools.execute('dns_lookup', {
args: { domain: 'example.com', type: 'A' }
});
console.log(result.data.result);
// Chat with Alfred
const reply = await alfred.chat.ask('Summarize this document...');
console.log(reply);
// Stream a response
for await (const chunk of alfred.chat.stream({ message: 'Write a story' })) {
if (chunk.type === 'text') process.stdout.write(chunk.content);
}
from alfred_sdk import AlfredClient
client = AlfredClient(api_key="ak_live_xxx_yyy")
# Execute a tool
result = client.tools.execute("dns_lookup", args={"domain": "example.com", "type": "A"})
print(result["data"]["result"])
# Chat with Alfred
reply = client.chat.ask("Summarize this document...")
print(reply)
# Stream a response
for chunk in client.chat.stream("Write a story"):
if chunk.get("type") == "text":
print(chunk["content"], end="", flush=True)
use AlfredAI\Alfred;
$alfred = new Alfred(['api_key' => 'ak_live_xxx_yyy']);
// Execute a tool
$result = $alfred->tools->execute('dns_lookup', ['domain' => 'example.com', 'type' => 'A']);
print_r($result['data']['result']);
// Chat with Alfred
$reply = $alfred->chat->ask('Summarize this document...');
echo $reply;
// Stream a response
foreach ($alfred->chat->stream('Write a story') as $chunk) {
if (($chunk['type'] ?? '') === 'text') {
echo $chunk['content'];
}
}
Full TypeScript definitions, Python type hints, and PHP 8.1+ strict types. Catch errors at compile time, not runtime.
Automatic retries with exponential backoff on transient errors and rate limits. No manual retry logic needed.
Native streaming for chat responses. Async iterators in Node.js, generators in Python, yield in PHP.
Built-in HMAC-SHA256 signature verification for incoming webhooks. Constant-time comparison to prevent timing attacks.
Typed exception classes for every error scenario — AuthError, RateLimitError, NotFoundError, ValidationError, and more.
Automatic tracking of rate limit headers. Access remaining quota after every request. Auto-wait on 429 responses.
const agent = await alfred.agents.create({
agent_name: 'Customer Support Bot',
agent_role: 'specialist',
task: 'Handle billing and account questions',
skills: ['product_lookup', 'ticket_create', 'refund_process'],
voice_enabled: true,
voice_engine: 'cartesia',
});
// Deploy the agent
await alfred.agents.deploy(agent.data.id, {
task: 'Monitor incoming support tickets',
auto_start: true,
});
console.log(`Agent ${agent.data.agent_name} deployed!`);
from alfred_sdk import AlfredClient
client = AlfredClient(api_key="ak_live_xxx_yyy")
for chunk in client.chat.stream(
"Analyze the security posture of my infrastructure",
tools=["security_scan", "vulnerability_check", "ssl_verify"],
):
if chunk.get("type") == "text":
print(chunk["content"], end="", flush=True)
elif chunk.get("type") == "tool_start":
print(f"\n🔧 Running {chunk['tool']}...", flush=True)
elif chunk.get("type") == "tool_end":
print(f" ✅ Done", flush=True)
use AlfredAI\Alfred;
use AlfredAI\Exceptions\RateLimitException;
$alfred = new Alfred(['api_key' => 'ak_live_xxx_yyy']);
try {
$result = $alfred->tools->execute('seo_audit', [
'url' => 'https://example.com',
'depth' => 3,
'check_mobile' => true,
]);
echo "Score: " . $result['data']['result']['score'] . "/100\n";
echo "Issues: " . count($result['data']['result']['issues']) . "\n";
} catch (RateLimitException $e) {
echo "Rate limited — retry in {$e->retryAfter}s\n";
}
// Create a voice room with an AI agent
const room = await alfred.voice.createRoom({
name: 'Sales Call',
max_participants: 3,
voice_engine: 'cartesia',
agent_id: 42,
});
console.log(`Room created: ${room.data.name}`);
console.log(`Join at: /voice/rooms/${room.data.id}`);
import express from 'express';
import { AlfredClient } from '@alfredai/sdk';
const alfred = new AlfredClient({ apiKey: 'ak_live_xxx_yyy' });
const app = express();
app.post('/webhooks/alfred', express.text({ type: '*/*' }), (req, res) => {
try {
const event = alfred.webhooks.verifyAndParse(
req.body,
req.headers['x-webhook-signature'] as string,
process.env.WEBHOOK_SECRET!,
);
console.log(`Received ${event.event}:`, event.data);
res.sendStatus(200);
} catch {
res.sendStatus(401);
}
});
Full TypeScript support with interfaces for every API type. Works with Node.js 18+ and modern browsers via bundlers.
Pythonic interface with type hints, generators for streaming, and support for both sync and async (httpx) workflows.
PSR-4 autoloading, PHP 8.1+ strict types, and native cURL HTTP client. Perfect for Laravel, Symfony, or vanilla PHP.
Get your API key from the Developer Portal and start integrating Alfred AI into your application today.
Someone from somewhere
just launched website.com
Just now