Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.shannon.run/llms.txt

Use this file to discover all available pages before exploring further.

Introduction

Shannon provides HTTP REST and gRPC APIs for submitting tasks, streaming results, and managing AI agent workflows. Base URL: http://localhost:8080 (development)

Quick Start

# Submit a task
curl -X POST http://localhost:8080/api/v1/tasks \
  -H "Content-Type: application/json" \
  -d '{"query": "Analyze sentiment: Shannon makes AI simple"}'

# Response
{
  "task_id": "task-dev-1234567890",
  "status": "submitted",
  "created_at": "2025-01-20T10:00:00Z"
}

# Stream real-time events
curl -N "http://localhost:8080/api/v1/stream/sse?workflow_id=task-dev-1234567890"

API Endpoints

Core Task Operations

EndpointMethodDescription
/api/v1/tasksPOSTSubmit a new task
/api/v1/tasks/streamPOSTSubmit task and get stream URL (201)
/api/v1/tasksGETList tasks with filters
/api/v1/tasks/{id}GETGet task status and result
/api/v1/tasks/{id}/streamGETStream events for a specific task
/api/v1/tasks/{id}/eventsGETGet task event history
/api/v1/tasks/{id}/timelineGETGet Temporal execution timeline

Task Control

EndpointMethodDescription
/api/v1/tasks/{id}/cancelPOSTCancel a running task
/api/v1/tasks/{id}/pausePOSTPause task at next checkpoint
/api/v1/tasks/{id}/resumePOSTResume a paused task
/api/v1/tasks/{id}/control-stateGETGet task control state (paused/running)

Real-Time Streaming

EndpointMethodDescription
/api/v1/stream/sse?workflow_id={id}GETServer-Sent Events stream
/api/v1/stream/ws?workflow_id={id}GETWebSocket stream

Session Management

EndpointMethodDescription
/api/v1/sessionsGETList sessions with pagination
/api/v1/sessions/{sessionId}GETGet session details
/api/v1/sessions/{sessionId}/historyGETGet session chat history
/api/v1/sessions/{sessionId}/eventsGETGet session events (grouped by turn)
/api/v1/sessions/{sessionId}PATCHUpdate session title (UUID or external_id)
/api/v1/sessions/{sessionId}DELETEDelete session (soft delete; 204 idempotent)

Schedules (Recurring Tasks)

EndpointMethodDescription
/api/v1/schedulesPOSTCreate a new schedule
/api/v1/schedulesGETList schedules with filters
/api/v1/schedules/{id}GETGet schedule details
/api/v1/schedules/{id}/runsGETGet schedule execution history
/api/v1/schedules/{id}PUTUpdate schedule configuration
/api/v1/schedules/{id}/pausePOSTPause a schedule
/api/v1/schedules/{id}/resumePOSTResume a paused schedule
/api/v1/schedules/{id}DELETEDelete a schedule

Authentication

EndpointMethodDescriptionAuth Required
/api/v1/auth/registerPOSTRegister a new userNo
/api/v1/auth/loginPOSTLogin and get JWT tokensNo
/api/v1/auth/refreshPOSTRefresh JWT access tokenNo
/api/v1/auth/meGETGet current user infoYes
/api/v1/auth/refresh-keyPOSTRegenerate API keyYes
/api/v1/auth/api-keysGETList user’s API keysYes
/api/v1/auth/api-keysPOSTCreate new API keyYes
/api/v1/auth/api-keys/{id}DELETERevoke an API keyYes

Approvals

EndpointMethodDescription
/api/v1/approvals/decisionPOSTSubmit approval decision for human-in-the-loop tasks

OpenAI-Compatible API

Shannon provides an OpenAI-compatible API for easy integration with existing OpenAI SDKs and tools. See the OpenAI-Compatible API Reference for full details.
EndpointMethodDescription
/v1/chat/completionsPOSTChat completions (streaming supported)
/v1/modelsGETList available models
/v1/models/{model}GETGet specific model details

Health & Observability

EndpointMethodDescriptionAuth Required
/healthGETHealth checkNo
/readinessGETReadiness probeNo
/openapi.jsonGETOpenAPI 3.0 specNo

Authentication

Development Default: Authentication is disabled (GATEWAY_SKIP_AUTH=1). Enable for production.
When enabled, pass API key via header:
curl -H "X-API-Key: sk_test_123456" \
  http://localhost:8080/api/v1/tasks
SSE Streaming: Browser EventSource cannot send custom headers.
  • Development: set GATEWAY_SKIP_AUTH=1 to skip auth.
  • Production: initiate SSE from your backend (or edge) and inject X-API-Key or Authorization: Bearer headers.
  • For SSE endpoints, the api_key query parameter is supported as a fallback when headers cannot be sent.

Response Format

All endpoints return JSON with consistent error format: Success (200):
{
  "task_id": "task-dev-1234567890",
  "status": "COMPLETED",
  "result": "Sentiment: Positive"
}
Error (400/401/404/429/500):
{
  "error": "Task not found"
}

Rate Limiting

  • Default: 60 requests/minute per API key
  • Headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset
  • 429 Response: Includes Retry-After header

Event Streaming

Shannon emits 33 event types for real-time monitoring: Core Events:
  • WORKFLOW_STARTED, WORKFLOW_COMPLETED
  • AGENT_STARTED, AGENT_COMPLETED
  • STATUS_UPDATE, DATA_PROCESSING
  • ERROR_OCCURRED
LLM Events:
  • LLM_PROMPT, LLM_OUTPUT, LLM_PARTIAL
Tool Events:
  • TOOL_INVOKED, TOOL_OBSERVATION
See Event Types Reference for the complete list. Python SDK: use the EventType enum for filtering and checks. See SDK Streaming.

Client Access

Use the Gateway REST API or the Python SDK (HTTP-only):
  • REST endpoints: http://localhost:8080/api/v1/*
  • Python SDK: ShannonClient(base_url="http://localhost:8080")
Note: gRPC services are internal and not part of the public SDK surface. The OpenAI-compatible /v1/chat/completions endpoint is intended for compatibility. For full Shannon features (skills, session workspaces, research strategies), use /api/v1/tasks and related endpoints.

Best Practices

1. Use Session IDs for Context

{
  "query": "What about Q2?",
  "session_id": "user-123-analytics"
}

2. Stream Events for Long Tasks

import requests

r = requests.get(
    f"http://localhost:8080/api/v1/stream/sse?workflow_id={task_id}",
    stream=True
)

for line in r.iter_lines():
    if line:
        event = parse_sse(line)
        print(event['type'])

3. Handle Rate Limits

import time

def submit_with_retry(query, max_retries=3):
    for attempt in range(max_retries):
        response = requests.post(url, json={"query": query})

        if response.status_code == 429:
            retry_after = int(response.headers.get("Retry-After", 60))
            time.sleep(retry_after)
            continue

        return response

4. Use Idempotency Keys

curl -X POST http://localhost:8080/api/v1/tasks \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"query": "Process once"}'

SDKs

Python SDK

Official Python client with streaming support

REST Clients

Use any HTTP client library

Next Steps

Submit Tasks

Task submission API

Stream Events

Real-time event streaming

Sessions API

Session management

Authentication

API keys and JWT authentication

Task Control

Pause, resume, and cancel tasks

Python SDK

Get started with Python