Umbrella SDK

One object, one key, every service, with each client built only when you first use it.

aice-sdk (Python) and @aiceafrica/sdk (TypeScript) put every service client behind one Aice object. Each sub-client is built the first time you touch it, so importing the umbrella costs nothing for services you never call.

import os
from aice import Aice

aice = Aice(
    api_key=os.environ["AICE_API_KEY"],
    user_id=current_user.id,
    user_role=current_user.role,
    reco_vertical="ecommerce",                # the vertical aice.reco reads and writes
    base_urls={
        "reco": "https://reco.example.com",
        "knowledge": "https://kb.example.com/knowledge",
        "crawler": "https://crawler.example.com/crawl",
        "agent-platform": "https://agents.example.com",
        "kyc": "https://kyc.example.com/api/v1/kyc",
        "data-brain": "https://brain.example.com",
        "email": "https://email.example.com/email",
        "sandbox": "https://sandbox.example.com",
    },
)

recs = aice.reco.recommend("user-1", n=10)
hits = aice.knowledge.search("payment terms")
jobs = aice.crawler.jobs.list()
draft = aice.email.drafts.create(sender_id=sender_id, recipient_group_id=group_id, subject="Hi")
out = aice.sandbox.session.create().exec(["python3", "-c", "print(6 * 7)"])

Each URL includes the service's path; see Service URLs. A service you leave out falls back to a bare local port without its path, so list every service you call.

Recommendation's URL is the bare host, and its vertical goes in reco_vertical / recoVertical. Without it, aice.reco can still list verticals, but every other call fails before it is sent.

Sub-clients

PythonTypeScriptClient
aice.agent_platformaice.agentPlatformAgent Platform
aice.recoaice.recoRecommendation
aice.knowledgeaice.knowledgeKnowledge
aice.crawleraice.crawlerCrawler
aice.data_brainaice.dataBrainData Brain
aice.emailaice.emailEmail
aice.kycaice.kycKYC
aice.sandboxnot yetSandbox

The Python base_urls keys are kebab-case ("agent-platform", "data-brain"); the TypeScript keys are camelCase.

Recommendation is reco on the umbrella even though its class is RecommendationClient. That short name is kept on purpose as the stable handle.

Which user each sub-client sends

The umbrella's user_id / userId and user_role / userRole reach every sub-client. user_scopes / userScopes reach only Knowledge and Email, the two services that read X-User-Scopes. The key itself is scope-checked when you first touch a sub-client: if the project doesn't have that service enabled, you get InsufficientScopeError before any request.

aice = Aice(api_key=key, user_id=user.id, user_role="admin", user_scopes=["finance", "email:pii"])
aice.knowledge.search("payment terms")   # narrowed to the "finance" scope

Timeouts and retries

timeout (seconds in Python, milliseconds in TypeScript) and max_retries / maxRetries are set once and inherited by every sub-client.

Serving many users

The umbrella passes its user to each sub-client. To act for someone else per request:

from aice_core import acting_as

with acting_as(request.user.id, role=request.user.role):
    recs = aice.reco.recommend("user-1", n=10)

withUser returns a new Aice that rebuilds its sub-clients lazily; the original is untouched.

acting_as doesn't reach aice.agent_platform: that client fixes its user when it's built, and the umbrella builds it once. For the Agent Platform in a multi-user backend, build an AgentPlatformClient per user instead.

What isn't included

  • Observability isn't an API client. It's a telemetry bootstrap for your own services; see Observability.

On this page