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

Base URL

EnvironmentURL
Productionhttps://litellm-rust.onrender.com
Localhttp://localhost:4000

Create an agent

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

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

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

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

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!"}],
    },
)
See the API Reference for the full endpoint list.