# OpenAI-Compatible API A FastAPI-based service that provides OpenAI-compatible API endpoints with streaming support. Currently returns mock responses - ready for future Ollama/PydanticAI integration. ## Current Status **✅ Production-ready mock API** with OpenAI-compatible format **🚧 Ollama/PydanticAI integration** prepared but not connected ## Components - **FastAPI**: High-performance web framework providing the API layer - **SSE-Starlette**: Server-Sent Events for streaming responses - **Pydantic**: Type-safe request/response handling and validation - **Ollama Client**: Async HTTP client prepared for future integration - **PydanticAI**: Ready for LLM integration (not yet connected) ## Features - ✅ OpenAI-compatible API endpoints (`/v1/chat/completions`, `/v1/models`) - ✅ Streaming responses with Server-Sent Events (SSE) - ✅ Type-safe request/response handling with Pydantic - ✅ Async/await throughout for optimal performance - ✅ Comprehensive test suite (62% coverage) - ✅ Domain-based architecture following FastAPI best practices - 🚧 Ollama integration (client ready, not connected) - 🚧 PydanticAI integration (dependency installed, not connected) ## Requirements - Python 3.12+ (Python 3.12.11 recommended for security) - No external dependencies required for mock API - (Future: Network access to Ollama instance for LLM integration) ## Installation ### 1. Clone the repository ```bash git clone cd tatlock ``` ### 2. Create a virtual environment ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ``` ### 3. Install dependencies ```bash pip install -r requirements.txt ``` ### 4. Configure environment variables (Optional) Create a `.env` file in the project root for custom configuration: ```env # API Configuration API_HOST=0.0.0.0 API_PORT=8000 # Logging LOG_LEVEL=INFO # Future Ollama Configuration (not yet integrated) # OLLAMA_HOST=http://localhost:11434 # OLLAMA_DEFAULT_MODEL=mistral-nemo:latest # OLLAMA_TIMEOUT=120 ``` **Note**: The API works with defaults. Environment variables are optional for customization. Ollama configuration is prepared but not currently used. ## Usage ### Start the development server ```bash uvicorn src.main:app --reload ``` The API will be available at `http://localhost:8000` ### API Endpoints #### Chat Completions (OpenAI-compatible) Returns mock lorem ipsum responses: ```bash curl http://localhost:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "mistral-nemo:latest", "messages": [ {"role": "user", "content": "Hello, how are you?"} ], "stream": true }' ``` #### List Models Returns mock model listing: ```bash curl http://localhost:8000/v1/models ``` Response: `{"object": "list", "data": [{"id": "mistral-nemo:latest", ...}]}` ### Interactive API Documentation - Swagger UI: `http://localhost:8000/docs` - ReDoc: `http://localhost:8000/redoc` ## Security ### Version Locking Strategy This project uses minor version locking (`>=X.Y,