Seclai Python SDK
The official Python SDK for the Seclai API. Provides typed wrappers for the Seclai API, file uploads, SSE streaming, polling helpers, and full async support.
Requires Python 3.11+.
Install
pip install seclai
Exports
All public symbols are available from the top-level seclai package:
from seclai import (
Seclai, # Synchronous client
AsyncSeclai, # Asynchronous client
SeclaiError, # Base exception
SeclaiConfigurationError, # Missing API key / invalid config
SeclaiAPIStatusError, # Non-2xx HTTP response
SeclaiAPIValidationError, # HTTP 422 validation error
SeclaiStreamingError, # SSE stream error event
AgentRunStreamRequest, # TypedDict for streaming run requests
JSONValue, # Recursive JSON type alias
)
Quick start
from seclai import Seclai
client = Seclai(api_key="...")
# List agents
agents = client.list_agents()
print(agents)
# Run an agent and stream the result
from seclai import AgentRunStreamRequest
run = client.run_streaming_agent_and_wait(
"agent_id",
body=AgentRunStreamRequest(input="Summarize the latest uploads", metadata={}),
timeout=60.0,
)
print("run:", run.run_id, "status:", run.status)
Async client
import asyncio
from seclai import AsyncSeclai
async def main():
async with AsyncSeclai(api_key="...") as client:
agents = await client.list_agents()
print(agents)
asyncio.run(main())
Configuration
| Option |
Environment variable |
Default |
api_key |
SECLAI_API_KEY |
— |
access_token |
— |
— |
profile |
SECLAI_PROFILE |
"default" |
config_dir |
SECLAI_CONFIG_DIR |
~/.seclai |
auto_refresh |
— |
True |
account_id |
— |
— |
timeout |
— |
30.0 (seconds) |
api_key_header |
— |
x-api-key |
default_headers |
— |
None |
http_client |
— |
None (auto-created httpx.Client) |
Ten methods wait without limit unless you pass timeout yourself: run_agent(),
list_agent_runs(), get_agent_run(), delete_agent_run(), list_sources(),
get_content_detail(), delete_content(), list_content_embeddings(),
upload_file_to_source() and upload_file_to_content(). The 30-second default
does not apply to them, and neither does the timeout of an http_client you
supply. Requests from every other method use a supplied client's own timeout.
Set SECLAI_API_URL to point at a different API host (e.g., staging):
export SECLAI_API_URL="https://staging-api.seclai.com"
Authentication
Credentials are resolved via a chain (first match wins):
- Explicit
api_key option
- Explicit
access_token option (string or callable)
SECLAI_API_KEY environment variable
- SSO — cached tokens from
~/.seclai/sso/cache/ (always available as fallback)
# API key
client = Seclai(api_key="sk-...")
# Static bearer token
client = Seclai(access_token="eyJhbGciOi...")
# Dynamic bearer token provider (sync callable, called per request)
client = Seclai(access_token=lambda: get_token_from_vault())
# Async provider — use AsyncSeclai for async callables
client = AsyncSeclai(access_token=get_token_async)
# SSO profile (uses cached tokens, auto-refreshes)
client = Seclai(profile="my-profile")
# Environment variable (no options needed)
# export SECLAI_API_KEY="sk-..."
client = Seclai()
SSO authentication
SSO is the default fallback when no explicit credentials are provided. The SDK
includes built-in production SSO defaults, so no configuration is needed:
npx @seclai/cli auth login # authenticate via browser — works immediately
To customize SSO settings (e.g. for a staging environment), use seclai configure sso
or set environment variables:
| Variable |
Description |
Default |
SECLAI_SSO_DOMAIN |
Cognito domain |
auth.seclai.com |
SECLAI_SSO_CLIENT_ID |
Cognito app client ID |
4bgf8v9qmc5puivbaqon9n5lmr |
SECLAI_SSO_REGION |
AWS region |
us-west-2 |
API documentation
Online API documentation (latest):
https://seclai.github.io/seclai-python/1.11.0/
API versioning
The API dates its backward-incompatible changes. Nothing changes for you until
you opt in, either per client or by pinning the account:
from seclai import ApiVersion
client = Seclai(api_key="...", api_version=ApiVersion.V2026_07_27) # Seclai-Version header
state = client.get_api_version() # what this request resolved to
client.update_api_version(ApiVersion.V2026_07_27) # pin the whole account
Leave api_version unset and the header is omitted, so the account's pinned
baseline applies and responses keep their current shapes. Upgrading this package
alone never changes the wire contract.
Known versions are on the ApiVersion string enum, alongside
DEFAULT_API_VERSION and LATEST_API_VERSION. A version this release was
not built against raises SeclaiConfigurationError: a newer version can
reshape responses, and this client would decode them incorrectly rather than
reject them. Upgrade the package to adopt a new version, or pass
allow_unknown_api_version=True if you have to move first and accept that risk.
The guard covers the header however it reaches the wire: api_version,
default_headers, a per-request headers argument, or the default headers of
an http_client you supply, which are checked at construction and again on
each request, exactly as a value in default_headers is. It covers nothing
else. An account pinned server-side can still be
newer than this release — get_api_version() reports the effective_version the
request resolved to, and comparing it against LATEST_API_VERSION is how you
detect the gap.
What 2026-07-27 changes. Undeclared query parameters become a 422 instead
of being ignored, and every list endpoint that answered with a bare array or
under a per-resource key moves to the canonical
{"data": [...], "pagination": {...}} envelope. The methods for those endpoints
return what they document on either shape, so code written against the default
still reads the result after you opt in:
| Declared return |
Methods |
From 2026-07-27 |
| A list |
list_evaluation_criteria(), list_run_evaluation_results(), get_agent_callers(), list_inbound_email_rejections(), list_governance_ai_conversations(), list_solution_conversations(), list_models(), list_memory_bank_templates(), get_agents_using_memory_bank(), list_cloud_drive_providers(), list_cloud_drives(), get_agents_using_cloud_drive(), list_cloud_drive_rejections() |
Unchanged |
data, from a bare array by default |
list_evaluation_criteria_page(), list_run_evaluation_results_page() |
data, plus pagination |
data with flat total/page/limit |
list_evaluation_results(), list_agent_evaluation_results(), list_evaluation_runs(), list_compatible_runs() |
Unchanged, plus pagination |
| A per-resource key |
list_agent_email_optouts() and list_blocked_email_senders() / set_auto_block_mode() (items), list_alert_configs() (configs), list_organization_alert_preferences() (preferences), list_email_domains() (domains), list_knowledge_bases() (knowledge_bases), list_memory_banks() (memory_banks), list_model_alerts() (alerts), list_experiments() (experiments), get_generation_tiers() (tiers), list_embedding_models() and list_reranker_models() (models) |
The same key, plus data and pagination |
Where a method documents flat total, page or limit, the client fills them
from pagination after you opt in. Fields that sit beside a list, such as
auto_block_mode, the embedding defaults or the email-domain plan capabilities,
are present on both shapes. pagination is present only once you opt in, so
read it with .get("pagination").
A 200 response that is not a list at all — an error-shaped object, text, or an
empty body — raises SeclaiError from every one of these methods.
unwrap_items() still reads either shape of any of these results.
Opting in also turns paging on for endpoints that returned everything by
default, so the same call can return fewer rows:
list_evaluation_criteria() and list_run_evaluation_results() return every
item by default and ignore page/limit. After you opt in they return one
page: 50 items unless you pass limit, since this client sends limit=50.
The list carries no sign of that; use list_evaluation_criteria_page() or
list_run_evaluation_results_page() to see pagination.
list_alert_configs() ignores page and limit by default and returns every
config; after you opt in it returns one page of 50.
set_auto_block_mode() returns the first 50 blocked senders on either shape.
Its total is the account's full count by default, and the number of rows it
returned after you opt in.
Later versions. Each is cumulative, and none changes a response shape this
client decodes: