Logo
Search
API Docs

Python Server SDK

Chat Agents

Python Server SDK: Backend Automation & Outbound Calling

Overview

Unlike the Flutter, React Native, and iOS SDKs covered elsewhere in this section, the Python Server SDK is a server-side SDK — it runs on your backend, not in a client app, and uses your private API key rather than a public one. It's best suited for backend automation: placing outbound calls, routing inbound calls, syncing with your CRM, processing webhooks, and running custom-LLM logic behind your own endpoint.


Installation & Client Setup

Install the package with pip:

pip install sulus_server_sdk

Initialize the client with your private API key, read from an environment variable rather than hardcoded:

import os
from sulus import SulusClient

client = SulusClient(token=os.getenv("SULUS_API_KEY"))

Creating an Outbound Call

Use client.calls.create() to place an outbound call, supplying the phone number to call from, the destination number, and the assistant to handle the call:

call = client.calls.create(
    phone_number_id="YOUR_PHONE_NUMBER_ID",
    customer={"number": "+1234567890"},
    assistant_id="YOUR_ASSISTANT_ID"
)

print(f"Call created: {call.id}")
  • phone_number_id — the ID of the phone number registered in your Sulus account to call from
  • customer — a dict containing the destination number in E.164 format (e.g. +1234567890)
  • assistant_id — the ID of the assistant that will handle the call

For a lower-level walkthrough of the same operation via the raw API, see Creating a Single Outbound Call via API.


Custom-LLM Server Pattern

The Python Server SDK is also commonly used alongside a small backend service that implements your own model logic behind a chat-completions-style endpoint, so an assistant's model provider can point at your server instead of a hosted one. A minimal Flask example:

from flask import Flask, request, jsonify

app = Flask(__name__)

@app.route("/chat/completions", methods=["POST"])
def chat_completions():
    payload = request.get_json()
    messages = payload.get("messages", [])

    # Your own model / business logic goes here
    reply = "This is a custom response from your own model endpoint."

    return jsonify({
        "choices": [
            {"message": {"role": "assistant", "content": reply}}
        ]
    })

if __name__ == "__main__":
    app.run(port=5000)

Point your assistant's model configuration at this endpoint's public URL to route conversation turns through your own logic instead of a hosted model.


Key Resources & Next Steps

What you'll need:

  • A private, server-side API key (see CLI & API Key Auth for how to retrieve and manage it)
  • A phone number ID for outbound calling
  • An assistant ID for the assistant handling the call

Because it runs entirely server-side, this SDK is best suited for backend automation such as outbound campaigns, inbound call routing, CRM integration, and webhook processing — not for embedding directly in a client app.