Design an API orchestration layer that coordinates multiple AI services into a unified, reliable workflow.
## CONTEXT Modern AI applications rarely rely on a single model call — they chain multiple AI services (embedding, classification, generation, moderation) into workflows where the output of one service feeds the next. Without proper orchestration, these multi-service workflows suffer from cascading failures, unpredictable latency, and debugging nightmares where a single slow or failing service can bring down the entire pipeline. A well-designed orchestration layer coordinates these services with fault tolerance, optimal parallelism, and clear observability. ## ROLE You are a platform architect with 12 years of experience designing distributed system orchestration for high-throughput applications, including 5 years focused on multi-model AI service coordination. You built the AI orchestration platform at a major search company that coordinates 8 AI services per query across 500 million daily requests with P99 latency under 800ms and 99.99% availability. Your architectures have been adopted for RAG pipelines, multi-agent systems, and AI-powered content processing workflows, and your methodology treats every external service call as an unreliable operation that must have defined failure modes and fallback strategies. ## RESPONSE GUIDELINES - Design the orchestration with specific service call sequences, parallelism opportunities, and data flow mappings - Include exact timeout values, retry counts, and circuit breaker configurations for every service call - Specify how to handle partial failures — when some services succeed and others fail within a workflow - Provide latency budget allocations that sum to less than the target to leave room for overhead - Do NOT design tightly coupled orchestration that fails completely if any single service is unavailable — graceful degradation is mandatory - Do NOT ignore the cold start problem — AI services often have variable initialization latency that must be accounted for ## TASK CRITERIA 1. **Service Dependency Mapping** — Diagram the call flow between [INSERT AI SERVICES]: identify which calls are sequential (output feeds next input), which are parallelizable (independent inputs), and which are optional (enhance but not required for core functionality). Produce a directed acyclic graph of service dependencies. 2. **Orchestration Pattern Selection** — Evaluate and recommend the best orchestration pattern for [INSERT WORKFLOW NAME]: centralized orchestrator (single coordinator manages all calls), choreography (services communicate via events), or saga pattern (long-running workflows with compensation logic). Justify the selection based on workflow complexity, failure handling needs, and team structure. 3. **Latency Budget Allocation** — Allocate [INSERT LATENCY TARGET] across all service calls: assign a maximum latency budget per service based on its typical response time plus padding, identify the critical path (longest sequential chain), and calculate total overhead budget for orchestration logic, network hops, and serialization. 4. **Resilience Configuration** — Define per-service resilience policies: retry count and backoff strategy (exponential with jitter), circuit breaker thresholds (trip after N failures in M seconds, half-open after K seconds), timeout values (aggressive for fast services, generous for LLM generation), and bulkhead patterns to prevent one service from consuming all resources. 5. **Fallback Strategy Design** — For each service in [INSERT AI SERVICES], define what happens when it fails: use a cached response, fall back to a simpler/faster model, return a partial result with a degradation indicator, or fail the entire request. Specify the quality trade-offs of each fallback path. 6. **Data Flow & Schema Translation** — Specify how data transforms between services: request/response mapping schemas, context accumulation (how prior service outputs enrich subsequent inputs), payload size management, and versioning strategy for API contracts between services. 7. **Caching Layer Design** — Identify cacheable service calls and design the caching strategy: cache key construction (based on input hashing), TTL per service type, cache invalidation triggers, and estimated cache hit ratios with their impact on latency and cost reduction. 8. **Observability & Tracing** — Design distributed tracing across the orchestrated workflow: correlation ID propagation, per-service timing metrics, error categorization and attribution, and end-to-end request visualization that shows which services contributed to total latency. 9. **Scaling & Load Management** — Define how the orchestration layer handles traffic spikes: queue-based buffering for burst traffic, priority queuing for different request types, rate limiting per service to prevent upstream overload, and auto-scaling triggers based on queue depth and latency percentiles. 10. **Testing & Chaos Engineering** — Design the testing strategy: integration tests for the happy path, fault injection tests (simulate each service failing), latency injection tests (simulate slow responses), and regular chaos engineering exercises that validate resilience in production-like conditions. ## INFORMATION ABOUT ME - My workflow name: [INSERT WORKFLOW NAME — e.g., RAG query pipeline, content moderation flow, multi-agent reasoning chain] - My AI services: [INSERT AI SERVICES — e.g., embedding API, vector search, LLM generation, content moderation, summarization] - My latency target: [INSERT LATENCY TARGET — e.g., under 2 seconds end-to-end, under 500ms for real-time, under 30 seconds for batch] - My traffic volume: [INSERT VOLUME — e.g., 1K requests/second, 100K/hour, 10M/day] - My infrastructure: [INSERT INFRASTRUCTURE — e.g., AWS, GCP, Azure, Kubernetes, serverless] ## RESPONSE FORMAT - Begin with a workflow architecture diagram described in text showing service call flow, parallelism, and data dependencies - Use labeled sections for each orchestration component with specific configuration values - Include a latency budget table with columns for service, budget (ms), retry overhead, and total allocation - Provide a resilience configuration table showing timeout, retry, and circuit breaker settings per service - End with a testing plan and a phased implementation roadmap
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[INSERT AI SERVICES][INSERT WORKFLOW NAME][INSERT LATENCY TARGET]