Skip to main content
Version: 0.2.0

REST API

Agent Kernel provides a built-in REST API server for agent interaction.

Starting the API Server

from agentkernel.api import RESTAPI

if __name__ == "__main__":
RESTAPI.run()

Or from CLI:

python my_agent.py

Endpoints

POST /chat

Execute an agent with a message.

Request:

{
"agent": "assistant",
"message": "What is 2 + 2?",
"session_id": "user-123"
}

Response:

{
"response": "2 + 2 equals 4.",
"agent": "assistant",
"session_id": "user-123"
}

GET /agents

List all available agents.

Response:

{
"agents": ["assistant", "math", "code"]
}

GET /health

Health check endpoint.

Response:

{
"status": "healthy",
"version": "0.1.2b17"
}

Error Handling

400 Bad Request:

{
"error": "Missing required field: agent"
}

404 Not Found:

{
"error": "Agent not found: nonexistent"
}

500 Internal Server Error:

{
"error": "Agent execution failed",
"details": "Error details..."
}

Streaming

Support for streaming responses will be available soon

POST /chat/stream

Best Practices

  • Use unique session IDs per conversation
  • Handle errors gracefully
  • Implement rate limiting in production
  • Use HTTPS in production
  • Add authentication
  • Monitor API performance