Skip to content

Client

The Client is the entry point to the Teler SDK. It wraps the REST API, attaches your API key to every request, and exposes resource managers (today: client.calls).

Pass your API key to the constructor. The Python Client is sync; Python’s AsyncClient and Node’s Client are async by default.

Both Python clients support the context-manager protocol so resources are released automatically. The Node client doesn’t require explicit cleanup.

The constructor throws a BadParametersException if the key is empty.

# Sync
from teler import Client
with Client("YOUR_API_KEY") as client:
call = client.calls.create(...)
# Async
from teler import AsyncClient
async with AsyncClient("YOUR_API_KEY") as client:
call = await client.calls.create(...)

Every request sends an X-API-Key header with your key. The Node client applies a 10-second per-request timeout; the Python client uses the underlying HTTP library’s default.

See Authentication for key creation, rotation, and storage best practices.

POST /api/v1/calls/initiate HTTP/1.1
Host: api.frejun.ai
X-API-Key: YOUR_API_KEY
Content-Type: application/json

client.calls.create() initiates an outbound call. Teler dials to_number from from_number, then fetches your Call Flow from flow_url to determine what to do once the call is answered.

FieldTypeRequiredDefault
from_numberstring (E.164)yesnone
to_numberstring (E.164)yesnone
flow_urlstring (HTTPS)yesnone
status_callback_urlstring (HTTPS)yesnone
recordbooleannotrue
from teler import Client
with Client("YOUR_API_KEY") as client:
call = client.calls.create(
from_number="+918065xxxx",
to_number="+919967xxxx",
flow_url="https://your-domain.com/flow",
status_callback_url="https://your-domain.com/webhook",
record=False,
)
print(call.id)

client.calls.create() can raise a typed exception, but the two SDKs differ in which HTTP statuses they convert. See Errors for the full hierarchy and try/catch patterns.

HTTPNodePython
401UnauthorizedExceptionnot converted (surfaces as a raw response error)
403ForbiddenExceptionForbiddenException
any other non-2xxTelerException (.code = HTTP status)not converted

The Node client auto-maps 401 and 403 and wraps everything else as a generic TelerException. The Python client only auto-maps 403 to ForbiddenException; other non-2xx responses are not turned into typed exceptions. BadParametersException in Python comes from client-side validation (for example, an empty API key), not from the server.

from teler import Client
from teler.exceptions import ForbiddenException, TelerException
try:
call = client.calls.create(...)
except ForbiddenException:
print("from_number not on this account")
except TelerException as e:
print(f"Teler error: {e}")