Quickstart

Get a project key from the console and make your first authenticated call.

This walks through one call to the Knowledge service. Every other service follows the same four steps; only the client class changes.

Get your project key

Sign in to the console, open the project, and go to API key. Copy the key. It's shown once, so store it straight away in your backend's secret store or environment:

.env
AICE_API_KEY="eyJhbGciOiJSUzI1NiIs…"

The key covers the services enabled on that project. Each project has its own key and its own data. Generating a new one replaces the old one.

Install the client

pip install aice-knowledge

Python 3.11 or newer; Node 18 or newer (the TypeScript packages are ESM only). Installation lists every package.

Create a client

The client needs the service's URL, your key, and the user the request acts for. That user is a UUID from your own system; see the acting user.

The service URL includes the service's path: /knowledge here. Service URLs lists them all.

import os
from aice_knowledge import KnowledgeClient

client = KnowledgeClient(
    base_url=os.environ["AICE_KNOWLEDGE_URL"],  # http://localhost:6100/knowledge locally
    api_key=os.environ["AICE_API_KEY"],
    user_id=current_user.id,
)

Make a call

hits = client.search("payment terms", top_k=5)
print(hits)

A 401 means the key is wrong or expired. A 403 usually means the user or role you sent isn't allowed to do this. Errors covers every case.

Next

On this page