Skip to main content

Base Module Overview

The Base Module provides the primary interface layer for ARKOS, including a FastAPI server with OpenAI-compatible endpoints and an interactive CLI for testing.

Core Components

FastAPI Server

OpenAI-compatible /v1/chat/completions endpoint with streaming support

CLI Interface

Interactive command-line interface for testing and development

OAuth Authentication

Google OAuth integration for per-user tool authentication

Health Monitoring

Health check endpoint for system status

Architecture

FastAPI Server (app.py)

Starting the Server

This starts the server on port 1111 by default.

Endpoints

POST /v1/chat/completions

OpenAI-compatible chat completions endpoint:
Request Format:
Response Format:

GET /health

Health check endpoint:

Streaming Responses

Startup Initialization

CLI Interface (main_interface.py)

Starting the CLI

Features

  • Interactive conversation loop
  • Type messages and press Enter to send
  • Type exit or quit to stop
  • Rich terminal output support (main_interface_rich.py)

Basic Usage

OAuth Authentication (auth.py)

Routes for per-user OAuth authentication:

Google Calendar OAuth Flow

  1. User calls /auth/google/login?user_id=alice
  2. Redirects to Google OAuth consent screen
  3. Google redirects to /auth/google/callback
  4. Token stored in UserTokenStore
  5. User can now use Google Calendar tools

Configuration

Environment Variables

YAML Configuration

Using the API

Python Client

cURL

Tool System Prompt

Tools are formatted for the system prompt:

Error Handling

The server handles common error cases:
  • Missing LLM server: Health check reports llm_server: "not_running"
  • Database errors: Logged with traceback
  • Tool auth required: Returns structured error for frontend handling

Deployment

Development

Production with Uvicorn

Shared Server Considerations

On shared servers like MIT SIPB:
  1. Check if LLM server is already running on port 30000
  2. Use unique ports if running multiple instances
  3. Coordinate with team on port assignments

Troubleshooting

Ensure the server is running:
Check if SGLang is running:
Verify user has connected the service:
Find and kill the process:

Next Steps

Agent Module

Learn about agent orchestration

Tool Module

Explore tool integration

Quick Start

Get started with ARKOS

API Reference

Complete API documentation