calute.api_server.routers#
FastAPI routers for the OpenAI-compatible API endpoints.
This module provides the routing infrastructure for the Calute API server, including: - Chat completion endpoints (standard and Cortex) - Models listing endpoint - Health check endpoint - Unified routing for mixed agent types
Each router class encapsulates the endpoint logic for a specific functionality group, following the modular architecture pattern. The routers support both streaming and non-streaming responses, with full OpenAI API compatibility.
- class calute.api_server.routers.ChatRouter(agents: dict[str, calute.types.agent_types.Agent], completion_service: CompletionService)[source]#
Bases:
objectRouter for chat completion endpoints.
Provides the /v1/chat/completions endpoint for standard Calute agents, supporting both streaming and non-streaming responses with full OpenAI API compatibility.
- agents#
Dictionary mapping agent IDs to Agent objects.
- completion_service#
Service for handling chat completions.
- router#
FastAPI APIRouter instance with configured routes.
- class calute.api_server.routers.CortexChatRouter(cortex_completion_service: CortexCompletionService)[source]#
Bases:
objectRouter for Cortex chat completion endpoints with multi-agent orchestration.
Provides the /v1/chat/completions endpoint for Cortex-based multi-agent orchestration, supporting both task mode and instruction mode with various execution strategies (sequential, parallel, hierarchical).
- cortex_completion_service#
Service for handling Cortex completions.
- router#
FastAPI APIRouter instance with configured routes.
- class calute.api_server.routers.HealthRouter(agents: dict[str, calute.types.agent_types.Agent])[source]#
Bases:
objectRouter for health check endpoints.
Provides the
/healthendpoint for server health monitoring, returning the server status and the number of registered agents. This is typically used by load balancers, container orchestrators, or monitoring systems to verify the server is operational.- agents#
Dictionary mapping agent IDs to
Agentobjects. The length of this dictionary is reported in health responses.
- router#
FastAPI
APIRouterinstance with configured routes.
- class calute.api_server.routers.ModelsRouter(agents: dict[str, calute.types.agent_types.Agent])[source]#
Bases:
objectRouter for models listing endpoints.
Provides the /v1/models endpoint that lists all available agents and models, following the OpenAI API specification.
- agents#
Dictionary mapping agent IDs to Agent objects or model configs.
- router#
FastAPI APIRouter instance with configured routes.
- class calute.api_server.routers.UnifiedChatRouter(agents: dict[str, calute.types.agent_types.Agent] | None = None, completion_service: calute.api_server.completion_service.CompletionService | None = None, cortex_completion_service: calute.api_server.cortex_completion_service.CortexCompletionService | None = None)[source]#
Bases:
objectUnified router that handles both standard and Cortex chat completions.
Routes incoming requests to either standard Calute agents or Cortex multi-agent orchestration based on the model name in the request. This provides a single endpoint that supports all agent types.
- agents#
Dictionary mapping agent IDs to Agent objects.
- completion_service#
Service for standard agent completions.
- cortex_completion_service#
Service for Cortex completions.
- router#
FastAPI APIRouter instance with configured routes.