# AgentLine SDKs

Use an SDK only inside application code. For one-off agent actions, use REST
with `curl`.

## Python

The package is `agentline-ai`; the import is `agentline_ai`. PyPI `agentline` is
a different project.

```bash
pip install agentline-ai
```

```python
import os
from agentline_ai import AgentLine

client = AgentLine(api_key=os.environ["AGENTLINE_API_KEY"])

agent = client.agents.create(
    name="Support Bot",
    system_prompt="You are a helpful assistant. Be concise.",
    initial_greeting="Hello! How can I help?",
    voice_id="female-1",
)
client.numbers.buy(agent_id=agent.id, country="US", area_code="415")
call = client.calls.create(agent_id=agent.id, to_number="+12125557890")
print(client.calls.get_transcript(call.id))
```

Resources:

```python
client.agents     # create, list, get, update, delete
client.numbers    # buy, list, get, attach, reassign, release (destructive)
client.calls      # create, list, get, get_transcript, hangup, push_context
client.messages   # list, list_conversations
client.events     # poll, peek
client.webhooks   # list, set, delete, test
client.billing    # get_balance, get_expenditure, get_summary, ...
client.voice      # list, get, set, reset
```

Push context to a live call:

```python
client.calls.push_context(call.id, turn_id="turn_xxx", context="Order ships Tuesday.", disposition="done")
```

## Node

There is no Node package on npm yet; `npm i agentline` is not AgentLine. Use
`fetch`:

```javascript
const base = "https://api.agentline.cloud";
const headers = {
  Authorization: `Bearer ${process.env.AGENTLINE_API_KEY}`,
  "Content-Type": "application/json",
};

const agent = await fetch(`${base}/v1/agents`, {
  method: "POST",
  headers,
  body: JSON.stringify({ name: "Support Bot", initial_greeting: "Hello! How can I help?" }),
}).then((r) => r.json());

await fetch(`${base}/v1/numbers`, {
  method: "POST",
  headers,
  body: JSON.stringify({ agent_id: agent.id, country: "US", area_code: "415" }),
});

const call = await fetch(`${base}/v1/calls`, {
  method: "POST",
  headers,
  body: JSON.stringify({ agent_id: agent.id, to_number: "+12125557890" }),
}).then((r) => r.json());

const transcript = await fetch(`${base}/v1/calls/${call.id}/transcript`, { headers }).then((r) => r.json());
```

Both SDK and REST follow the OpenAPI (https://api.agentline.cloud/openapi.json).

AgentLine: https://agentline.cloud | API: https://api.agentline.cloud | All guides: https://agentline.md
