Metadata-Version: 2.5
Name: insightfactory-sdk
Version: 8.0.6.5
Summary: Insight Factory REST API client
Project-URL: Homepage, https://insightfactory.ai
Author-email: "insightfactory.ai Support" <support@insightfactory.ai>
License-Expression: LicenseRef-Proprietary
License-File: LICENSE
Keywords: insightfactory.ai,openapi,sdk
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.28.1
Requires-Dist: insightfactory-cli<2,>=1.2.0
Requires-Dist: pydantic>=2.11
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: typing-extensions>=4.7.1
Description-Content-Type: text/markdown

# insightfactory-sdk

Async Python client for the Insight Factory REST API.

Authenticate with an if-cli profile, which supplies the host and a fresh token
refreshed the way `if-cli token` does, or with a bearer token you already have:

```python
from insightfactory import ApiClient, configure
from insightfactory_sdk.api.tasks_api import TasksApi

config = configure(profile_name="foundry-dev")
# config = configure(token=token, host="https://your-factory.insightfactory.ai")

async with ApiClient(config) as client:
    tasks = await TasksApi(client).tasks_get()
```

Pass exactly one of `profile_name` or `token`. With `profile_name`, the host
always comes from that profile. A conflicting `host=` is rejected so a profile
token is never sent to another factory. Profiles and tokens come from the
`insightfactory-cli` store at `~/.insightfactory`, or `INSIGHTFACTORY_CONFIG_DIR`
when set. A missing or logged-out profile raises, and the error names the
`if-cli login` command to run. `insightfactory-cli` is a declared dependency, so
it installs with the SDK.

`Configuration(host=..., access_token=...)` still works if you already have both.

`insightfactory.ApiClient` is the generated `ApiClient` plus an `X-IF-UA` header
that names the SDK to the factory: `insightfactory-sdk/<version>`. A tool that
drives the SDK can put its own product token first by exporting
`INSIGHTFACTORY_UA`, for example `if-fde-harness/5.10.0`. A value that is not a
valid product token is ignored. `insightfactory_sdk.ApiClient` still works and
sends no `X-IF-UA`.

Every operation is `async` and non-blocking, over a pooled `httpx.AsyncClient`.
Each also has a `_sync` twin for scripts and notebooks. The twin builds its own
client, outside any `async with` block:

```python
config = configure(profile_name="foundry-dev")
sync_client = ApiClient(config)
tasks = TasksApi(sync_client).tasks_get_sync()
```

`_sync` runs the coroutine on a dedicated background event loop, so never call
it from inside `async` code. `await` the async method there instead.

Don't mix the two styles on one `ApiClient`. The first request creates the
connection pool and binds it to whichever loop issued it, so a client used both
ways fails on the other loop, usually as an `Event loop is closed` error far
from the call that caused it. Use a separate client for each style.

## Licence

Copyright 2026 insightfactory.ai. All rights reserved. This package is proprietary
and may be used only under a separate written agreement with insightfactory.ai.
