Skip to content
FAC Suite

Developers

Put the assistant in your own software.

Everything FAC Cloud does is available from Python. Stream a conversation, search the knowledge base, run a workflow, read usage — the same API the FAC Chat client uses.

pip install assistant-runtime-sdk — version 1.9.0, AGPL-3.0.

from assistant_runtime_sdk import AssistantRuntimeClient

client = AssistantRuntimeClient(
    tenant_id="your-tenant-id",
    tenant_secret="your-secret",
    ar_url="https://api.fac-cloud.com",
)

for event in client.stream_chat(
    session_id="session-123",
    message="Which invoices are overdue this week?",
    user_id="[email protected]",
    model_id="auto",
):
    if event["event"] == "stream_chunk":
        print(event["data"].get("content", ""), end="", flush=True)

Quick start

Three steps from nothing to a verified connection. The full documentation covers everything past that.

  1. Install the package

    Python 3.10+. The async client is an optional extra.

    pip install assistant-runtime-sdk
  2. Add your credentials

    Issued when your site is connected to the hosted service. Keep the secret out of source control — the sample below reads them from the environment.

    export AR_TENANT_ID="your-tenant-id"
    export AR_TENANT_SECRET="your-secret"
  3. Make your first request

    Confirms the credentials and the connection in one call, without spending credits on a model.

    import os
    
    from assistant_runtime_sdk import AssistantRuntimeClient
    
    client = AssistantRuntimeClient(
        tenant_id=os.environ["AR_TENANT_ID"],
        tenant_secret=os.environ["AR_TENANT_SECRET"],
        ar_url="https://api.fac-cloud.com",
    )
    
    print(client.get_tenant_info())

Where the SDK sits

Your code talks to the hosted service. The ERP tools come from the app on your own site, so the SDK sees exactly what the chat client sees.

Your code Any Python process.
Yours.
The Python SDK One pip install.
Yours.
FAC Cloud Chat, memory and workflows.
Hosted by us.
Your ERP site Records and audit log.
Yours.
Model providers Under enterprise terms.
Third parties.

The package

Everything on this page is checkable in about ten seconds, which is why it is stated rather than described.

Packageassistant-runtime-sdk.Import as assistant_runtime_sdk.
LicenceAGPL-3.0.Open source.
Python3.10+.Tested on current releases.
SDK sourcebuildswithpaul/assistant_runtime_sdk.The client you import.
App sourcebuildswithpaul/Frappe_Assistant_Core.A different repository: the app your site installs.

How it authenticates

AuthenticationHMAC over your tenant secret.There is no bearer token to leak.
Model selectionmodel_id="auto".The runtime picks the model for the question.
AsyncAsyncAssistantRuntimeClient.The same surface, for use inside an event loop.

What the client covers

Chat and streamingSend a message and read the reply as it is generated, including tool calls as they run.
ConversationsList, read and manage sessions and their message history.
Knowledge baseUpload documents, search them, and manage what the assistant can draw on.
MemoryRead and write the long-term facts the assistant keeps about a user.
WorkflowsTrigger workflows and read their runs.
UsersAdd and remove members, and set per-person credit limits.
Billing and usageRead plans, credit balances and consumption.

Install

Two extras, one package. The async client shares the sync client's surface.

pip install assistant-runtime-sdk           # sync client
pip install "assistant-runtime-sdk[async]"  # with async support

Before you start

Getting credentials

The SDK authenticates as a tenant: you need a tenant ID and secret, which are issued when your site is connected to FAC Cloud. If you are already running FAC Chat, you have them. If not, get in touch and we will set you up.

Costs are the same

Calls made through the SDK draw on the same credit allowance as the chat client, and appear in the same usage breakdown. See the plans.

Four more calls

Past streaming: a file upload, a trigger, a read and an administrative write. The reference has the rest.

Add a document to the knowledge base

Uploaded once, then available to every conversation on your tenant. Public here means your whole team, not the internet.

client.upload_document(
    file_path="handbook.pdf",
    user_id="[email protected]",
    visibility="public",
)

Run a workflow

Triggers a workflow by its document name and returns the run.

client.execute_workflow(
    name="WF-00001",
    input_data="{\"customer\": \"Acme Corp\"}",
    user_id="[email protected]",
)

Read what has been spent

A daily credit rollup grouped by source, for the last thirty days.

client.get_consumption_breakdown(days=30)

Cap one person's monthly spend

Zero means no personal cap: that user draws on the shared pool.

client.set_user_credit_limit(
    user_id="[email protected]",
    monthly_credit_limit=500,
    acted_by="[email protected]",
)

When it goes wrong

Every one of these subclasses ARError, so a single except clause catches the lot while these five tell you what to do about it.

What the client raises.
ExceptionWhenWhat to do
ARAuthenticationErrorThe tenant ID or secret is wrong, or the tenant is not connected.Check both values, then confirm the site is still connected.
ARRateLimitErrorToo many requests in the window.Back off and retry; the exception carries the retry hint.
ARBillingUnavailableErrorThe credit allowance is exhausted, or billing is not reachable.Check the balance before retrying — a retry will not succeed on its own.
ARTimeoutErrorThe request exceeded its timeout.Raise the client timeout for long generations, or stream instead.
ARConnectionErrorThe hosted service could not be reached at all.A network or DNS problem rather than a credentials one.

Build on it

Install the app on your site, then work against the Python SDK from your own code. Both are open source.

See what it costs · Read the source.

Talk to us about your ERP

How should we get in touch?

Monday to Friday, 9:30 am to 6:30 pm IST.