Skip to main content

Provider Architecture

Interface Abstraction

Implementations:
  • GroqProvider: Primary LPU-accelerated inference
  • BytezProvider: Fallback for reliability

Provider Factory

Model → Provider Routing:

Groq Provider

API Configuration

Chat Completion Request

Streaming Implementation

Error Handling

Bytez Provider

API Configuration

Implementation Differences

Request Format: Similar to OpenAI API Response Parsing: Expects OpenAI-compatible response structure Timeout: Same 45-second limit Streaming: Not currently implemented (fallback is non-streaming only)

Failover Chain

Single Chat Failover

Total Max Time: 135 seconds (3 × 45s) Logging: Each failure logged with attempt number

Dual Chat Failover

Each model has independent fallback chain:
Outcomes:
  1. ✅ Both succeed → Full dual-chat response
  2. ⚠️ One succeeds → Partial response with error note
  3. ❌ Both fail → 500 error

Performance Characteristics

Response Times

Groq (LPU):
  • Simple prompt: 500-1500ms
  • Complex prompt: 1500-3000ms
  • Streaming first token: 100-300ms
Bytez:
  • Simple prompt: 1500-3000ms
  • Complex prompt: 3000-5000ms

Timeout Strategy

45-Second Rationale:
  • Balances user patience with completion probability
  • Most responses complete within 30 seconds
  • Allows fallback attempts within reasonable total time
Alternative Approaches:
  • Shorter timeout (30s): More frequent fallbacks
  • Longer timeout (60s): Fewer fallbacks but slower failover

Rate Limits

Groq Free Tier:
  • 30 requests/minute
  • 14,400 tokens/minute
Groq Paid Tier:
  • Higher limits (check API dashboard)
Bytez:
  • Provider-specific limits (not documented here)
Handling: 429 Too Many Requests triggers fallback chain

Model Registry Integration

Model Lookup

Response:

Provider Assignment

Static Mapping (current):
Database-Driven (future):

Provider-Specific Features

Groq LPU Advantages

Low Latency: Hardware-optimized tensor processing Fast Streaming: Sub-300ms first token latency Cost: Competitive pricing on per-token basis Models: Llama, Mixtral, Gemma families

Bytez Reliability

Uptime: Independent from Groq (diversification) Fallback: Critical for production availability Models: Variety beyond Groq’s catalog

Monitoring & Observability

Metrics to Track

Provider Success Rate:
Response Time Percentiles:
  • p50 (median)
  • p95
  • p99
Timeout Rate:
Fallback Frequency:
  • How often does primary fail?
  • How often does secondary succeed?

Alerting Thresholds

High Timeout Rate: > 10% of requests timeout Low Success Rate: < 95% for primary provider Fallback Dependency: > 20% of requests use fallback

Configuration

Environment Variables

HttpClient Configuration

Resilience: HttpClient connection pooling and DNS refresh handled automatically

Future Enhancements

Adaptive Routing

Route based on:
  • Model performance metrics
  • Current provider latency
  • Rate limit status
  • Cost optimization

Circuit Breaker

Trigger: Open circuit after N consecutive failures Reset: Close circuit after cooldown period

Response Caching

Deterministic Requests (temperature = 0):
Non-Deterministic: No caching (current behavior)

Next Steps

Request Lifecycle

Provider execution in request flow

System Invariants

Provider timeout and fallback invariants