Skip to main content

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", "/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", "/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)

Run an agent with SSE streaming (wait for final result)

This helper returns when the stream emits the final done event. It raises if the stream ends early or timeout is reached.

from seclai import Seclai

client = Seclai(api_key="...")

run = client.run_streaming_agent_and_wait(
	"11111111-1111-4111-8111-111111111111",
	body={
		"input": "Hello from streaming",
		"metadata": {"app": "My App"},
	},
	timeout=60.0,
)

print(run)

Async:

import asyncio

from seclai import AsyncSeclai


async def main() -> None:
	async with AsyncSeclai(api_key="...") as client:
		run = await client.run_streaming_agent_and_wait(
			"11111111-1111-4111-8111-111111111111",
			body={"input": "Hello from streaming"},
			timeout=60.0,
		)
		print(run)


asyncio.run(main())

Get agent run details

Get details of a specific agent run, optionally including per-step outputs:

from seclai import Seclai

client = Seclai(api_key="...")

# Basic details
run = client.get_agent_run(
	"11111111-1111-4111-8111-111111111111",
	"22222222-2222-4222-8222-222222222222",
)
print(run)

# Include per-step outputs with timing, durations, and credits
run = client.get_agent_run(
	"11111111-1111-4111-8111-111111111111",
	"22222222-2222-4222-8222-222222222222",
	include_step_outputs=True,
)
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.

Max file size: 200 MiB.

Supported MIME types:

  • application/epub+zip
  • application/json
  • application/msword
  • application/pdf
  • application/vnd.ms-excel
  • application/vnd.ms-outlook
  • application/vnd.ms-powerpoint
  • application/vnd.openxmlformats-officedocument.presentationml.presentation
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • application/xml
  • application/zip
  • audio/flac, audio/mp4, audio/mpeg, audio/ogg, audio/wav
  • image/bmp, image/gif, image/jpeg, image/png, image/tiff, image/webp
  • text/csv, text/html, text/markdown, text/x-markdown, text/plain, text/xml
  • video/mp4, video/quicktime, video/x-msvideo

If the upload is sent as application/octet-stream, the server attempts to infer the type from the file extension.

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.4/

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 lint and make test before opening a PR.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seclai-1.0.4.tar.gz (111.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seclai-1.0.4-py3-none-any.whl (310.1 kB view details)

Uploaded Python 3

File details

Details for the file seclai-1.0.4.tar.gz.

File metadata

  • Download URL: seclai-1.0.4.tar.gz
  • Upload date:
  • Size: 111.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for seclai-1.0.4.tar.gz
Algorithm Hash digest
SHA256 76e6499bed5b56e82ddb72d1153dd993b40dfec6ac08f4b27f1b4a6ef5ceae75
MD5 122d591cfe8a7bbe37102d04c99397ed
BLAKE2b-256 0b0cd31761e036439e213f046eb111d58077f2354234d071510d26ad08aba3d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for seclai-1.0.4.tar.gz:

Publisher: main-build.yaml on seclai/seclai-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file seclai-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: seclai-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 310.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for seclai-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d1354d6f3cbb5f2fafec7d93af143b09cdc1884ddcb0e2d0e3b588b91752e712
MD5 50d8991cfa0167bc1265024c111c6dc2
BLAKE2b-256 71f816b1d2dc48ad41363e9f0d8a179d030741e876af3792f660336b65a0ae5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for seclai-1.0.4-py3-none-any.whl:

Publisher: main-build.yaml on seclai/seclai-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page