Menu
Client Methods

Initialization & Authentication

ReflexioClient setup for Hosted Enterprise and Local OSS.

ReflexioClient

The main client class for interacting with the Reflexio API. The same ReflexioClient works against both deployment modes — only the install package, the URL, and whether you need an API key change.

Python
from reflexio import ReflexioClient

client = ReflexioClient()  # uses REFLEXIO_API_KEY env var
Terminal
curl -X GET "https://www.reflexio.ai/api/whoami" \
  -H "User-Agent: my-agent-reflexio" \
  -H "Authorization: Bearer $REFLEXIO_API_KEY"
PropTypeDefaultDescription
url_endpoint?str""Base URL for the API. Falls back to REFLEXIO_URL, then to Hosted Enterprise at https://www.reflexio.ai/.
api_key?str""API key for authentication. Falls back to REFLEXIO_API_KEY. Required for Hosted Enterprise; not required by default for Local OSS.
timeout?float300Default request timeout in seconds.

The SDK and CLI share one URL env var. Both the Python client and the reflexio CLI read REFLEXIO_URL, defaulting to https://www.reflexio.ai/. Set it once (or pass --server-url / url_endpoint explicitly) and both tools agree.

The Python client resolves a nonblank url_endpoint first, then REFLEXIO_URL, then the managed-cloud default. IS_TEST_ENV does not select an endpoint. For an old test setup with active or unrecognized IS_TEST_ENV, supply an explicit URL; otherwise construction raises ValueError before creating a transport, preventing an implicit local connection from changing to managed cloud.


Setup

Hosted Enterprise

The hosted endpoint at https://www.reflexio.ai and API key authentication require a Reflexio Enterprise account.

Hosted Enterprise registration is open — no invitation required. If you do not have an account yet, create one from the registration page with email and password (then verify your email) or sign up with Google or GitHub.

Install the lightweight client package — it has only the SDK and a handful of pure-Python deps:

Terminal
pip install reflexio-client

Set your API key as an environment variable, then create the client with no arguments:

Terminal
export REFLEXIO_API_KEY="your-api-key"
Python
from reflexio import ReflexioClient

client = ReflexioClient()  # url defaults to https://www.reflexio.ai/

# Ready to use immediately
response = client.get_config()
Terminal
curl -X GET "https://www.reflexio.ai/api/get_config" \
  -H "User-Agent: my-agent-reflexio" \
  -H "Authorization: Bearer $REFLEXIO_API_KEY"

You can also pass the API key directly:

Python
client = ReflexioClient(api_key="your-api-key")

API keys are shown only once when created. Store the value somewhere secure, because the web portal only displays the saved prefix afterward. If a key is lost, create a new key and delete the old one.

Install the full open-source package — it bundles the client, the FastAPI server, and the reflexio CLI:

Terminal
pip install reflexio-ai

Start the local server:

Terminal
reflexio services start  # listens on http://localhost:8081

Point the client at it. No API key is needed — the open-source server runs without authentication by default.

Python
from reflexio import ReflexioClient

client = ReflexioClient(url_endpoint="http://localhost:8081")

# Ready to use immediately
response = client.get_config()
Terminal
curl -X GET "http://localhost:8081/api/get_config" \
	  -H "User-Agent: my-agent-reflexio"

Or use the env var:

Terminal
export REFLEXIO_URL="http://localhost:8081"
Python
from reflexio import ReflexioClient

client = ReflexioClient()  # auto-reads REFLEXIO_URL

Session-scoped client

Use for_session to bind one session ID for search, publishing, and lifecycle calls: client.for_session(session_id: str) -> SessionScopedClient. The ID must be non-empty after trimming whitespace. The returned view shares the original client's connections, authentication, configuration, and cache.

Python
session = client.for_session("conversation-123")
context = session.search(query="How do I refund?", user_id="user-1")

The view's session_id property returns the bound ID. Passing a different explicit session ID to a scoped call raises ValueError. Methods that do not involve a session are forwarded unchanged.

The view's client property returns the underlying unscoped ReflexioClient; use it when a call should not use the bound session.

Environment variables

Variables the Python client reads. Explicit constructor parameters always take precedence.

VariablePurpose
REFLEXIO_API_KEYAPI key for authentication. Required for Hosted Enterprise; not required by default for Local OSS. API keys are shown only once when created.
REFLEXIO_URLBase URL for the API. Defaults to Hosted Enterprise at https://www.reflexio.ai/. Set to http://localhost:8081 for Local OSS.

The reflexio CLI reads the same REFLEXIO_URL env var, so a single setting configures both the SDK and the CLI. See the CLI Reference for details.


Client Behavior

Sync and native async API

The client remains synchronous by default. publish_interaction_async() and search_async() are native async counterparts for hosted async integrations; await them directly. Both use the same request construction, response models, and configured total timeout as their synchronous counterparts.

Fire-and-Forget Mode

Several methods use fire-and-forget by default: the call returns None immediately and the operation runs in the background. Set wait_for_response=True to block until the server confirms.

Methods with optional fire-and-forget (wait_for_response=False by default):

  • delete_interaction, delete_profile, delete_request, delete_session, delete_agent_playbook, delete_user_playbook, rerun_profile_generation, rerun_playbook_generation, run_playbook_aggregation

Methods that are always fire-and-forget (no blocking option):

  • manual_profile_generation, manual_playbook_generation

publish_interaction always blocks on the HTTP round-trip and returns a PublishUserInteractionResponse — the wait_for_response flag controls only whether the server processes extraction synchronously before returning, not the client transport.

Caching

get_profiles and get_agent_playbooks cache results locally for 10 minutes. After publishing new data, pass force_refresh=True to bypass the cache and fetch fresh results.

Errors and transport

The client sends requests with HTTPX. Blocking calls raise:

ExceptionWhen
httpx.HTTPStatusErrorThe API returns a 4xx or 5xx status. Read the code from exc.response.status_code.
httpx.TransportError subclasses, such as httpx.ConnectError and httpx.ReadTimeoutThe server cannot be reached, or a phase exceeds timeout.
reflexio.client.client.ReflexioAPIErrorThe API answers with a redirect, or with a success status whose body is not JSON. This usually means REFLEXIO_URL points at the wrong host.

The client never follows redirects. timeout applies to each connection phase. Blocking calls honor the HTTP(S)_PROXY and NO_PROXY variables, and they verify TLS against REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE, or SSL_CERT_FILE / SSL_CERT_DIR when one is set.