Source Code:
src/gaia/api/The GAIA API Server implements a subset of OpenAI’s Chat Completions API with GAIA agents exposed as “models”.
http://localhost:8080 (default)
Architecture:
Endpoints
Health Check
GET /health
Check API, Lemonade LLM, and RAG component status
status is ok only when Lemonade has an LLM loaded, and
degraded when the LLM component is unavailable or error. RAG reports
not_configured until the document API is enabled.
GAIA reads loaded-model state from Lemonade’s /api/v1/health endpoint with a
350 ms timeout. The /api/v1/models catalog is not used for readiness because
downloaded models are not necessarily loaded.
Example:
List Models
GET /v1/models
List available GAIA agent models
Chat Completions
POST /v1/chat/completions
Create chat completion using a GAIA agent
Request Parameters
Message Object
Non-Streaming Response
- Request
- Response
Streaming Response
- Request
- Response (SSE)
Available Models
AGENT_MODELS in src/gaia/api/agent_registry.py holds one entry, gaia, mapping to the flagship GaiaAgent. GET /v1/models returns it. To expose another agent, add an entry — see Adding New Agents below.
Error Responses
All errors follow OpenAI’s error format.400 - Bad Request
404 - Model Not Found
500 - Internal Server Error
OpenAI API Compatibility
Supported Features
✅ Supported
/v1/chat/completions(streaming & non-streaming)/v1/modelsmessagesarray with rolestemperature,max_tokens,top_p- Server-Sent Events (SSE) streaming
❌ Not Supported
frequency_penalty,presence_penaltyfunctionsandtoolsparametersresponse_formatparameterlogprobs,n,stopparameters/v1/embeddings,/v1/audio/*,/v1/images/*
Adding New Agents
1
Create Agent Class
2
Register in Agent Registry
3
Restart Server
Security
Current Implementation:- ⚠️ Optional API key: set
GAIA_API_KEYand every chat completion must sendAuthorization: Bearer <key>(401 otherwise). Unset, loopback callers are allowed with a startup warning, and binding beyond loopback is refused. See Authentication. - ✅ CORS limited to loopback origins; add others with
GAIA_API_CORS_ORIGINS. Browser requests from any other origin are refused with 403. - ❌ No rate limiting
- Set
GAIA_API_KEY - Add rate limiting middleware
- Use HTTPS with valid certificates
See Also
API Server Guide
Usage examples and integration guides
VSCode Integration
VSCode extension setup