Seclai Python SDK
Project description
Seclai Python SDK
This is the official Seclai Python SDK.
Install
pip3 install seclai
Quickstart
Authentication
Provide your API key either:
- explicitly:
Seclai(api_key="..."), or - via environment variable:
SECLAI_API_KEY
Sync client
from seclai import Seclai
client = Seclai(api_key="...")
# Low-level request (escape hatch)
sources = client.request("GET", "/api/sources/")
print(sources)
Async client
import asyncio
from seclai import AsyncSeclai
async def main() -> None:
async with AsyncSeclai(api_key="...") as client:
sources = await client.request("GET", "/api/sources/")
print(sources)
asyncio.run(main())
Common examples
Run an agent
from seclai import Seclai
from seclai._generated.models.agent_run_request import AgentRunRequest
client = Seclai(api_key="...")
run = client.run_agent(
"11111111-1111-4111-8111-111111111111",
body=AgentRunRequest(
input_="Hello from the Seclai Python SDK!",
metadata={
"app": "My App"
},
),
)
print(run)
List sources
from seclai import Seclai
client = Seclai(api_key="...")
sources = client.list_sources(page=1, limit=20)
print(sources)
Upload a file to a source
You can upload either a filesystem path or bytes.
from seclai import Seclai
client = Seclai(api_key="...")
# Upload from path
resp = client.upload_file_to_source(
"22222222-2222-4222-8222-222222222222",
file="./document.pdf",
title="Example document",
)
print(resp)
from seclai import Seclai
client = Seclai(api_key="...")
# Upload from bytes
resp = client.upload_file_to_source(
"22222222-2222-4222-8222-222222222222",
file=b"hello world",
file_name="hello.txt",
mime_type="text/plain",
)
print(resp)
Error handling
Typed convenience methods raise exceptions for non-success responses.
from seclai import Seclai, SeclaiAPIStatusError
client = Seclai(api_key="...")
try:
sources = client.list_sources()
except SeclaiAPIStatusError as e:
print("Request failed:")
print("status:", e.status_code)
print("method:", e.method)
print("url:", e.url)
print("body:", e.response_text)
raise
Configuration
Timeouts and headers
from seclai import Seclai
client = Seclai(
api_key="...",
timeout=30.0,
default_headers={"x-my-app": "my-service"},
)
Development
Base URL
Set SECLAI_API_URL to point at a different API host (e.g., staging):
export SECLAI_API_URL="https://example.invalid"
Testing
make test
To pass args through to pytest:
make test ARGS='-k auth'
Formatting
make format
Linting
make lint
API documentation
Online API documentation (latest):
https://seclai.github.io/seclai-python/1.0.2/
Generate HTML docs into build/docs/:
make docs
OpenAPI spec & regenerating the client
Copy the OpenAPI JSON file into openapi/seclai.openapi.json, then run:
make generate
Reporting issues
If you hit a bug or have a feature request, please open an issue and include:
- what you were trying to do
- a minimal repro snippet (if possible)
- the exception / traceback
- your environment (Python version, OS)
Contributing
Contributions are welcome.
- Keep changes focused and add/adjust tests where appropriate.
- Run
make lintandmake testbefore opening a PR.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seclai-1.0.2.tar.gz.
File metadata
- Download URL: seclai-1.0.2.tar.gz
- Upload date:
- Size: 107.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3ae03aeaa2c309624fc20b4d578371e6d8aa864ad0ab6677a9990d286ccc45d
|
|
| MD5 |
884005ee01e75beb1b83bb970439f7f7
|
|
| BLAKE2b-256 |
c4dc1cf4e586c701bd0afc483a3e408577e8d2a9a09273f3156adb329ed2c3ce
|
Provenance
The following attestation bundles were made for seclai-1.0.2.tar.gz:
Publisher:
main-build.yaml on seclai/seclai-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seclai-1.0.2.tar.gz -
Subject digest:
c3ae03aeaa2c309624fc20b4d578371e6d8aa864ad0ab6677a9990d286ccc45d - Sigstore transparency entry: 814587129
- Sigstore integration time:
-
Permalink:
seclai/seclai-python@d946d55f30c2ad328fe3fae1dc5af630dd45f0c6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/seclai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-build.yaml@d946d55f30c2ad328fe3fae1dc5af630dd45f0c6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file seclai-1.0.2-py3-none-any.whl.
File metadata
- Download URL: seclai-1.0.2-py3-none-any.whl
- Upload date:
- Size: 302.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c616d62e51f2619fa48da6944a9a2e4ee022a9ba47a408c43af3edc4eb924d7f
|
|
| MD5 |
671be04528ad8dcf3e24c5a8a25f26e0
|
|
| BLAKE2b-256 |
95a8d23621c99aaeafb47847d3e71776578ca6510b0519471030a6dcb8dffe06
|
Provenance
The following attestation bundles were made for seclai-1.0.2-py3-none-any.whl:
Publisher:
main-build.yaml on seclai/seclai-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seclai-1.0.2-py3-none-any.whl -
Subject digest:
c616d62e51f2619fa48da6944a9a2e4ee022a9ba47a408c43af3edc4eb924d7f - Sigstore transparency entry: 814587153
- Sigstore integration time:
-
Permalink:
seclai/seclai-python@d946d55f30c2ad328fe3fae1dc5af630dd45f0c6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/seclai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-build.yaml@d946d55f30c2ad328fe3fae1dc5af630dd45f0c6 -
Trigger Event:
push
-
Statement type: