Memra SDK - Python Framework for Production AI Agents

Python SDK for Building Production AI Agents

Declarative framework for AI agents that handle document processing, data pipelines, and workflow automation. Self-hosted or managed cloud. SOC 2 Type II certified.

from memra import Agent, MemraCloud
import os

# Configure auth (or use MEMRA_API_KEY env var)
client = MemraCloud(api_key=os.environ['MEMRA_API_KEY'])

# Define agent with explicit capabilities
invoice_agent = Agent(
  name="invoice_processor",
  description="Extract and validate invoice data from PDFs",
  capabilities=["pdf_parse", "data_extraction", "validation"],
  model="gpt-4", # or "claude-3", "llama-2-70b"
  timeout_seconds=30,
  max_retries=3
)

# Run with structured I/O
result = await invoice_agent.run(
  input_file="invoice.pdf",
  validation_rules=validation_schema,
  output_format="json"
)

# Returns typed response with metadata
assert result.success
print(result.data) # {"vendor": "...", "amount": 1234.56, ...}
print(result.latency_ms) # 847
print(result.tokens_used) # {"prompt": 1823, "completion": 156}

Technical Specifications

Hard numbers for production deployments

Performance

  • Requests/second 1,000 RPS
  • P95 latency < 1.2s
  • P99 latency < 2.5s
  • Concurrent agents 10,000
  • Max file size 100 MB

Infrastructure

  • Regions US-East, EU-West
  • Uptime SLA 99.9%
  • Data retention 30 days
  • Deployment K8s / Docker
  • Min Python 3.8+

Models & Limits

  • GPT-4 8k context
  • Claude 3 100k context
  • Llama 2 4k context
  • Rate limit 1M tokens/hr
  • Batch size 1,000 docs

How It Actually Works

Architecture diagram showing request flow through load balancer, API gateway, agent orchestrator, and model endpoints

Your code → API Gateway → Agent Orchestrator → Model Router → Response. Full traces available via OpenTelemetry. Logs ship to your preferred sink (Datadog, CloudWatch, etc).

Production Use Cases

Real implementations with performance metrics

Invoice Processing Pipeline

1.2M docs/month
agent = Agent(
  name="invoice_processor",
  capabilities=["pdf_parse", "ocr", "validation"]
)
Accuracy: 98.4% Avg latency: 1.1s Cost: $0.0012/doc

Support Ticket Router

50k tickets/day
agent = Agent(
  name="ticket_classifier",
  capabilities=["classify", "prioritize", "route"]
)
Routing accuracy: 94% P95: 420ms False positive: 2.1%

Contract Analysis

10k contracts/week
agent = Agent(
  name="contract_analyzer",
  capabilities=["extract_terms", "risk_assessment"]
)
Clause detection: 96% Avg pages: 47 Processing: 8.3s
Current Limitations: Max 100MB per file, English-only OCR, no real-time streaming. Custom models require Enterprise plan. See full limitations.

Configuration & Deployment

Self-Hosted Setup

# docker-compose.yml
version: '3.8'
services:
  memra-api:
    image: memra/agent-runtime:2.4.1
    environment:
      - MODEL_ENDPOINTS=http://your-llm-gateway:8080
      - REDIS_URL=redis://cache:6379
      - POSTGRES_URL=postgresql://db/memra
      - TELEMETRY_ENDPOINT=http://otel-collector:4317
    deploy:
      replicas: 3
      resources:
        limits:
          cpus: '2'
          memory: 4G

# Terraform example at github.com/memra-platform/memra-terraform

Required Environment Variables

  • MEMRA_API_KEY - Your API key (get from dashboard)
  • MEMRA_REGION - Deployment region (us-east-1, eu-west-1)
  • MEMRA_LOG_LEVEL - Logging verbosity (INFO, DEBUG)
  • MEMRA_TELEMETRY_ENABLED - OpenTelemetry export (true/false)

Pricing

Usage-based with no hidden fees

Tier Price Included Overage
Developer $0/month 10k API calls $0.001 per call
Startup $299/month 500k API calls $0.0006 per call
Scale $999/month 5M API calls $0.0002 per call
Enterprise Custom Custom models, SLA, dedicated support Volume pricing

All tiers include: Multi-region deployment, 99.9% uptime SLA, Email support. Enterprise adds: Custom models, VPC peering, 24/7 phone support, Training.

Security & Compliance

SOC 2 Type II
Annual audit by Deloitte
GDPR Compliant
EU data residency available
HIPAA BAA
Available on Enterprise
End-to-end encryption
TLS 1.3 + AES-256 at rest
Zero data retention
Opt-in logging only
API key rotation
Automated with zero downtime

Full security documentation: docs.memra.co/security
Report vulnerabilities: security@memra.co (PGP available)

Start Building

Full SDK documentation, examples, and API reference available. Self-serve API keys in 2 minutes.

$ pip install memra
$ export MEMRA_API_KEY=your_key_here
$ python examples/invoice_processor.py

✓ Agent initialized
✓ Processing invoice.pdf...
✓ Extracted 14 fields in 1.1s
✓ Results saved to output.json