Skip to main content
The ai-query library uses a unified transport layer that decouples Agent Logic from Infrastructure. This allows you to write agent code once and deploy it anywhere—in a single process, across microservices, or on serverless functions.

Concepts

Agent Registry

The Registry maps Agent IDs (e.g., "researcher", "room-1") to their implementation. It solves the problem of “Where does this agent live?”.
  • Local Mapping: Maps an ID to a Python class. The AgentServer instantiates it on demand.
  • Remote Mapping: Maps an ID to a URL via a Transport. The agent lives on another server.

Transports

Transports handle the low-level communication between agents.
  • LocalTransport: Direct in-memory communication. Used when agents are in the same process.
  • HTTPTransport: Uses HTTP/REST to communicate with agents on other servers (or serverless functions).

Detailed API Reference

For comprehensive API documentation and examples, see:

Configuration

Basic (Single Agent Class)

The default behavior is simple: serve one type of agent for all IDs.

Advanced (Multi-Agent Registry)

Use AgentRegistry to serve multiple different agent types or route to remote agents.

Consuming Remote Agents

You don’t need AgentServer to use remote agents. You can use connect() in your client scripts or other applications.

Wire Protocol

HTTPTransport uses a standard JSON protocol over HTTP POST.

Endpoints

  • POST /{agent_id}/chat: Standard chat interaction.
  • POST /{agent_id}/invoke: RPC method calls.

Chat Request

Streaming Request

Response: text/event-stream with data: ... chunks.

Invoke Request