Advanced Agent Architecture
High-performance AI Agent APIs.
Build with production-grade AI agents using our typed SDKs, low-latency runtime, and sophisticated orchestration layer.
Developer Integration
Type-safe SDKs with comprehensive error handling and advanced features
npm install @swfte/agent-sdk --save
TypeScript SDK
// Initialize the Swfte Agent SDK with TypeScript support
import { SwfteAgent, AgentConfig, ChatResponse, FunctionResult } from '@swfte/agent-sdk';
// Configure agent with type-safe options
const config: AgentConfig = {
apiKey: process.env.SWFTE_API_KEY,
agentId: 'ag_12345',
maxTokens: 4096,
temperature: 0.7,
defaultHeaders: {
'X-Custom-Header': 'custom-value'
}
};
// Create a new agent instance with typed configuration
const agent = new SwfteAgent(config);
// Chat with the agent using async/await pattern
async function chatWithAgent(): Promise<ChatResponse> {
try {
const response = await agent.chat({
message: 'Analyze this dataset for anomalies',
context: {
previousMessages: [], // Thread history
userMetadata: { userId: 'user_123', plan: 'enterprise' }
}
});
console.log("Response received in " + response.latency + "ms");
return response;
} catch (error) {
console.error('Error chatting with agent:', error);
throw error;
}
}
// Call an agent function with structured parameters
async function callAgentFunction(): Promise<FunctionResult<any>> {
const result = await agent.callFunction('analyzeData', {
dataSource: {
type: 'url',
url: 'https://example.com/data.csv',
format: 'csv'
},
analysisParameters: {
detectOutliers: true,
confidenceThreshold: 0.85
}
});
return result;
}
Python SDK
# Initialize the Swfte Agent SDK with type hints
from typing import Dict, Any, List, Optional
from swfte import Agent, AgentConfig, ChatResponse, FunctionResult
# Configure agent with structured parameters
config = AgentConfig(
api_key=os.environ.get("SWFTE_API_KEY"),
agent_id="ag_12345",
max_tokens=4096,
temperature=0.7,
default_headers={"X-Custom-Header": "custom-value"}
)
# Create a new agent instance with configuration
agent = Agent(config)
# Chat with the agent using Python type hints
async def chat_with_agent() -> ChatResponse:
try:
response = await agent.chat(
message="Analyze this dataset for anomalies",
context={
"previous_messages": [], # Thread history
"user_metadata": {"user_id": "user_123", "plan": "enterprise"}
}
)
print(f"Response received in {response.latency}ms")
return response
except Exception as e:
print(f"Error chatting with agent: {e}")
raise
# Call an agent function with structured parameters
async def call_agent_function() -> FunctionResult:
result = await agent.call_function(
"analyzeData",
data_source={
"type": "url",
"url": "https://example.com/data.csv",
"format": "csv"
},
analysis_parameters={
"detect_outliers": True,
"confidence_threshold": 0.85
}
)
return result
# Stream responses for long-running operations
async def stream_agent_response():
async for chunk in agent.stream_chat(
message="Generate a comprehensive report on this dataset"
):
print(chunk.content, end="", flush=True)
REST API Client
// Make a typed HTTP request to the Agent API
interface ChatRequest {
message: string;
context?: {
previousMessages?: any[];
userMetadata?: Record<string, any>;
};
stream?: boolean;
}
interface ChatResponse {
id: string;
message: string;
completion_tokens: number;
prompt_tokens: number;
latency: number;
metadata: Record<string, any>;
}
async function chatWithAgent(request: ChatRequest): Promise<ChatResponse> {
const response = await fetch('https://api.swfte.ai/v1/agents/ag_12345/chat', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + process.env.SWFTE_API_KEY,
'X-Request-ID': crypto.randomUUID()
},
body: JSON.stringify(request)
});
if (!response.ok) {
const errorData = await response.json();
throw new Error('API Error: ' + errorData.message);
}
return response.json();
}
// Using the API with async/await and error handling
try {
const result = await chatWithAgent({
message: "Analyze this dataset for anomalies",
context: {
userMetadata: { projectId: "proj_789" }
}
});
console.log("Response received in " + result.latency + "ms");
} catch (error) {
console.error("API request failed:", error);
}
Enterprise Platform
Infrastructure for AI systems
Production-ready APIs with comprehensive authentication, rate limiting, retry logic, and observability built for mission-critical applications.
Enterprise-grade API
OpenAPI 3.0 compliant REST endpoints with structured request/response schemas, robust error handling, and comprehensive documentation.
// API Reference: Complete RESTful endpoints with OpenAPI 3.0 specification
// Create a new agent with advanced configuration
curl -X POST https://api.swfte.ai/v1/agents \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 1234567890" \
-d '{
"name": "Customer Support Agent",
"description": "Handles customer inquiries and resolves support tickets",
"model": "gpt-4-turbo",
"max_tokens": 8192,
"temperature": 0.7,
"knowledge_base_ids": ["kb_123456"],
"functions": [
{
"name": "queryOrderStatus",
"description": "Get the current status of a customer order",
"parameters": {
"type": "object",
"required": ["order_id"],
"properties": {
"order_id": {
"type": "string",
"description": "The order identifier"
}
}
}
}
],
"system_prompt": "You are a helpful customer support assistant..."
}'
// Multi-turn conversation with streaming support
curl -X POST https://api.swfte.ai/v1/agents/ag_123456/chat \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"stream": true,
"messages": [
{
"role": "system",
"content": "You are a helpful customer support assistant."
},
{
"role": "user",
"content": "I need help with my order status"
}
],
"thread_id": "thread_789012",
"metadata": {
"user_id": "user_345678",
"session_id": "session_901234"
}
}'
API Architecture
- GraphQL API for flexible data querying alongside REST
- JWT and OAuth2.0 with multi-tenant support and RBAC
- Intelligent rate limiting based on tenant tiers
- Structured error responses with error codes and stack traces in development
- Automatic request validation against JSON Schema
- Comprehensive logging with distributed tracing (OpenTelemetry)
Engineering Excellence
Production-ready AI infrastructure
Enterprise-grade platform built for reliability, security, and performance at scale.
Sub-100ms latency
Optimized inference pipeline with edge caching, model quantization, and parallel execution paths.
SOC2 + HIPAA compliance
End-to-end encryption, VPC support, secure key management, and comprehensive audit logs.
Horizontal scalability
Auto-scaling architecture from zero to millions of requests with multi-region redundancy.
Advanced LLM capabilities
Function calling, RAG, tool use, multi-modal support, and custom fine-tuning with your data.
Content safety guardrails
Automated detection and filtering for PII, toxicity, hallucinations, and security vulnerabilities.
Extensible architecture
Robust plugin system, custom model support, and seamless integration with existing workflows.