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

# API

> Talk to your agents programmatically using the LAP REST API.

Every action available in the UI is also available over the REST API. Authenticate with `Authorization: Bearer <key>`.

## Base URL

| Environment | URL                                 |
| ----------- | ----------------------------------- |
| Production  | `https://litellm-rust.onrender.com` |
| Local       | `http://localhost:4000`             |

## Create an agent

```bash theme={null}
curl -X POST $LAP_URL/api/agents \
  -H "Authorization: Bearer $MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-agent",
    "owner_id": "local-user",
    "runtime": "cursor",
    "model": "claude-opus-4-5",
    "system": "You are a helpful assistant."
  }'
```

## Start and run a session

```bash theme={null}
SESSION=$(curl -s -X POST $LAP_URL/session \
  -H "Authorization: Bearer $MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "runtime": "cursor",
    "agent_id": "<agent-id>",
    "prompt": "Summarize the README."
  }' | jq -r .id)
```

## Send another prompt

```bash theme={null}
curl -X POST $LAP_URL/session/$SESSION/prompt_async \
  -H "Authorization: Bearer $MASTER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": { "modelID": "claude-opus-4-5" },
    "parts": [{ "type": "text", "text": "Summarize the README." }]
  }'
```

## Stream the response

```bash theme={null}
curl -N "$LAP_URL/v1/sessions/$SESSION/events/stream" \
  -H "Authorization: Bearer $MASTER_KEY"
```

Events are server-sent (SSE), newline-delimited:

```
data: {"type":"session.status_running"}
data: {"type":"agent.message","content":"Here is the summary..."}
data: {"type":"session.status_idle"}
```

## SDK examples

<CodeGroup>
  ```python Python theme={null}
  import requests

  session = requests.post(
      f"{LAP_URL}/session",
      headers={"Authorization": f"Bearer {MASTER_KEY}"},
      json={
          "runtime": "cursor",
          "agent_id": agent_id,
          "prompt": "Hello!",
      },
  ).json()

  requests.post(
      f"{LAP_URL}/session/{session['id']}/prompt_async",
      headers={"Authorization": f"Bearer {MASTER_KEY}"},
      json={
          "model": {"modelID": "claude-opus-4-5"},
          "parts": [{"type": "text", "text": "Hello!"}],
      },
  )
  ```

  ```javascript JavaScript theme={null}
  const session = await fetch(`${LAP_URL}/session`, {
    method: "POST",
    headers: { Authorization: `Bearer ${MASTER_KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({
      runtime: "cursor",
      agent_id: agentId,
      prompt: "Hello!",
    }),
  }).then(r => r.json());

  const stream = await fetch(`${LAP_URL}/v1/sessions/${session.id}/events/stream`, {
    headers: { Authorization: `Bearer ${MASTER_KEY}` },
  });
  ```
</CodeGroup>

See the [API Reference](/api-reference/overview) for the full endpoint list.
