> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy API: Agents Server

> HTTP API endpoints for agent servers

<Note>
  **Two Different API Servers**: This page documents the `Agent.launch()` HTTP server. For the auto-generated API server created by `praisonai deploy run --type api`, see [API Server Authentication](/features/api-server-auth).
</Note>

HTTP REST API endpoints for agents deployed via `Agent.launch()` or `Agents.launch()`.

## Base URL

```
http://localhost:{port}
```

Default port is `8000`.

## Endpoints

### POST /{path}

Send a query to the agent(s).

**Request:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl -X POST http://localhost:8000/ask \
  -H "Content-Type: application/json" \
  -d '{"query": "What is AI?"}'
```

**Request Body:**

| Field   | Type   | Required | Description         |
| ------- | ------ | -------- | ------------------- |
| `query` | string | Yes      | The message to send |

**Response:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "response": "Artificial intelligence (AI) refers to..."
}
```

**Response Fields:**

| Field      | Type   | Description      |
| ---------- | ------ | ---------------- |
| `response` | string | Agent's response |

### POST /{path}/{agent_id}

Call a specific agent in multi-agent setup.

**Request:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl -X POST http://localhost:8000/content/researcher \
  -H "Content-Type: application/json" \
  -d '{"query": "Research AI trends"}'
```

**Response:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "agent": "Researcher",
  "query": "Research AI trends",
  "response": "Current AI trends include..."
}
```

### GET /{path}/list

List available agents.

**Request:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl http://localhost:8000/content/list
```

**Response:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "agents": [
    {"name": "Researcher", "id": "researcher"},
    {"name": "Writer", "id": "writer"}
  ]
}
```

### GET /health

Health check endpoint.

**Request:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl http://localhost:8000/health
```

**Response:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "status": "ok",
  "endpoints": ["/ask", "/content"]
}
```

### GET /

Root endpoint with welcome message.

**Request:**

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl http://localhost:8000/
```

**Response:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "message": "Welcome to PraisonAI Agents API on port 8000. See /docs for usage.",
  "endpoints": ["/ask", "/content"]
}
```

### GET /docs

Swagger UI documentation.

**Request:**
Open in browser: `http://localhost:8000/docs`

## Error Responses

| Status | Description                                 |
| ------ | ------------------------------------------- |
| `400`  | Bad request - invalid JSON or missing query |
| `401`  | Unauthorized - invalid or missing API key   |
| `500`  | Internal server error                       |

**Error Format:**

```json theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
{
  "detail": "Missing 'query' field in request"
}
```

## Authentication

The `Agent.launch()` API server uses `X-API-Key` authentication when configured. When `api_key` is set in `launch()`:

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
curl -X POST http://localhost:8000/ask \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{"query": "Hello"}'
```

## Python Client

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import requests

response = requests.post(
    "http://localhost:8000/ask",
    json={"query": "What is machine learning?"},
    headers={"Content-Type": "application/json"}
)

print(response.json()["response"])
```

## Related

* [Agents Server](../agents-server) - Deploy agents as HTTP server
* [MCP API](./mcp-api) - MCP server endpoints
* [A2A API](./a2a-api) - A2A protocol endpoints
