Skip to main content
Source Code: src/gaia/api/
The GAIA API Server implements a subset of OpenAI’s Chat Completions API with GAIA agents exposed as “models”.
Base URL: http://localhost:8080 (default) Architecture:
External Client → FastAPI Server → GAIA Agents → Lemonade LLM Backend

Endpoints

Health Check

GET /health

Check server health status
Response:
{
  "status": "ok",
  "service": "gaia-api"
}
Example:
curl http://localhost:8080/health

List Models

GET /v1/models

List available GAIA agent models
Response Schema:
{
  "object": "list",
  "data": [
    {
      "id": "string",
      "object": "model",
      "created": 1234567890,
      "owned_by": "amd-gaia",
      "description": "string",
      "max_input_tokens": 32768,
      "max_output_tokens": 8192
    }
  ]
}
Example:
curl http://localhost:8080/v1/models

Chat Completions

POST /v1/chat/completions

Create chat completion using a GAIA agent
Supports both streaming (SSE) and non-streaming responses.

Request Parameters

ParameterTypeRequiredDefaultRangeDescription
modelstring✅ Yes--Model ID (e.g., “gaia-code”)
messagesarray✅ Yes--Array of message objects
streambooleanNofalse-Enable Server-Sent Events streaming
temperaturenumberNo0.70.0 - 2.0Sampling temperature
max_tokensintegerNo-> 0Maximum tokens to generate
top_pnumberNo1.00.0 - 1.0Nucleus sampling parameter

Message Object

FieldTypeRequiredValuesDescription
rolestring✅ Yes"system", "user", "assistant", "tool"Message role
contentstring✅ Yes-Message content
tool_callsarrayNo-Tool calls (assistant role only)
tool_call_idstringNo-Tool call ID (tool role only)

Non-Streaming Response

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gaia-code",
    "messages": [{"role": "user", "content": "Write a hello function"}],
    "stream": false
  }'

Streaming Response

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gaia-code",
    "messages": [{"role": "user", "content": "Write a hello function"}],
    "stream": true
  }'

Available Models

gaia-code

Autonomous Code Development

Python/TypeScript development agent with intelligent routing
PropertyValue
IDgaia-code
Max Input Tokens32768
Max Output Tokens8192
DescriptionAutonomous Python/TypeScript coding agent with planning, generation, and testing
Requirements:
  • Lemonade Server with --ctx-size 32768
  • Model: Qwen3-Coder-30B-A3B-Instruct-GGUF
Capabilities:
  • Code generation (functions, classes, projects)
  • Test generation
  • Linting & formatting (pylint, Black)
  • Error detection and correction
  • Project scaffolding
  • Architectural planning

Error Responses

All errors follow OpenAI’s error format.

400 - Bad Request

{
  "error": {
    "message": "messages is required",
    "type": "invalid_request_error",
    "code": "invalid_request"
  }
}

404 - Model Not Found

{
  "error": {
    "message": "Model 'gaia-invalid' not found. Available models: gaia-code",
    "type": "invalid_request_error",
    "code": "model_not_found"
  }
}

500 - Internal Server Error

{
  "error": {
    "message": "Agent processing failed: <details>",
    "type": "internal_error",
    "code": "agent_error"
  }
}

OpenAI API Compatibility

Supported Features

✅ Supported

  • /v1/chat/completions (streaming & non-streaming)
  • /v1/models
  • messages array with roles
  • temperature, max_tokens, top_p
  • Server-Sent Events (SSE) streaming

❌ Not Supported

  • frequency_penalty, presence_penalty
  • functions and tools parameters
  • response_format parameter
  • logprobs, n, stop parameters
  • /v1/embeddings, /v1/audio/*, /v1/images/*

Adding New Agents

1

Create Agent Class

# src/gaia/agents/myagent/agent.py
from gaia.agents.base.api_agent import ApiAgent
from gaia.agents.base.agent import Agent

class MyAgent(ApiAgent, Agent):
    def get_model_info(self):
        return {
            "max_input_tokens": 8192,
            "max_output_tokens": 4096,
        }
2

Register in Agent Registry

# src/gaia/api/agent_registry.py
AGENT_MODELS = {
    "gaia-myagent": {
        "class_name": "gaia.agents.myagent.agent.MyAgent",
        "init_params": {"silent_mode": True},
        "description": "My custom agent"
    }
}
3

Restart Server

gaia api stop
gaia api start

Security

Designed for local development only. Not production-ready.
Current Implementation:
  • ❌ No authentication
  • ❌ No rate limiting
  • ✅ CORS enabled (all origins)
For Production Deployment:
  • Implement API key authentication
  • Add rate limiting middleware
  • Configure CORS restrictions
  • Use HTTPS with valid certificates

See Also