sema4ai_api_client
A client library for accessing the Sema4.ai API.
Usage
First, create a client:
from sema4ai_api_client import Client
client = Client(base_url="https://api.example.com")
If the endpoints you're going to hit require authentication, use AuthenticatedClient instead:
from sema4ai_api_client import AuthenticatedClient
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
Now call your endpoint and use your models:
from sema4ai_api_client.models.my_data_model import MyDataModel
from sema4ai_api_client.api.my_tag import get_my_data_model
from sema4ai_api_client.types import Response
with client as client:
my_data: MyDataModel | None = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
Or do the same thing with an async version:
from sema4ai_api_client.models.my_data_model import MyDataModel
from sema4ai_api_client.api.my_tag import get_my_data_model
from sema4ai_api_client.types import Response
async with client as client:
my_data: MyDataModel | None = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
By default, HTTPS calls verify TLS certificates. You can provide a custom certificate bundle:
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl="/path/to/certificate_bundle.pem",
)
You can also disable certificate validation, but this is a security risk:
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl=False,
)
Things to know:
- Every path/method combo becomes a Python module with four functions:
sync: Blocking request that returns parsed data (if successful) orNonesync_detailed: Blocking request that always returns aResponse, withparsedset when successfulasyncio: Likesync, but asyncasyncio_detailed: Likesync_detailed, but async
- All path/query params and request bodies become function arguments.
- If an endpoint has tags, the first tag is used as the API module name.
- Endpoints without tags are available under
sema4ai_api_client.api.default.
Advanced customizations
You can customize the underlying httpx.Client / httpx.AsyncClient with httpx_args:
from sema4ai_api_client import Client
def log_request(request):
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
def log_response(response):
request = response.request
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
client = Client(
base_url="https://api.example.com",
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)
Or set an httpx client directly (this overrides shared settings like base_url unless you set them again):
import httpx
from sema4ai_api_client import Client
client = Client(base_url="https://api.example.com")
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxy="http://localhost:8030"))
Regenerate client
From the repo root:
make update-api-client
Or manually from packages/api-client:
uvx openapi-python-client generate \
--path "../../workroom/packages/agent-server-interface/public.openapi.json" \
--config "openapi-client-config.yaml" \
--meta none \
--output-path "sema4ai_api_client"
Build
uv build
Install locally into another project:
uv pip install dist/sema4ai_api_client-*.whl
Release
Releases are published to PyPI automatically via GitHub Actions using trusted publishers (OIDC). No API tokens are needed.
Steps
-
Update the version in
pyproject.toml. -
Commit and push the version change to
main. -
Create and push a tag matching the pattern
sema4ai-api-client-<version>:# Or use the invoke task which validates the branch and version: pip install invoke && invoke make-release
Alternatively, tag manually:
git tag -a sema4ai-api-client-3.0.0 -m "Release 3.0.0" git push origin sema4ai-api-client-3.0.0
-
The
api-client-release.ymlworkflow picks up the tag, builds the package, and publishes it to PyPI.
Prerequisites
A trusted publisher must be configured on PyPI for the sema4ai-api-client project:
- Owner:
Sema4AI - Repository:
moonraker - Workflow:
api-client-release.yml - Environment: (leave blank)
Metadata
Release files for sema4ai-api-client 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sema4ai_api_client-3.0.0.tar.gz | 83.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sema4ai_api_client-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 327.6 kB
Release files / sema4ai_api_client-3.0.0.tar.gz
| Download URL | sema4ai_api_client-3.0.0.tar.gz |
|---|---|
| Size | 83.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de32d41a86e6e4a13c5c98fc1cd8409d4e9156346aa524e8b764dd451f0159dc
|
|
BLAKE2b-256 checksum How to use checksums |
fe6619f34a78b704100f5c1c8a8f99b9f2c791fb6d90010c9fbf239d36585902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.
Transparency logRelease files / sema4ai_api_client-3.0.0-py3-none-any.whl
| Download URL | sema4ai_api_client-3.0.0-py3-none-any.whl |
|---|---|
| Size | 243.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b9d847f8e9e93c62cf45543d5909df1ce5161f2eb8e29ad02fb2ab7378800ed
|
|
BLAKE2b-256 checksum How to use checksums |
ebd98927e9ba01964d847e55ff91fdb62e0fe12662111b6e240c9378006d387a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 31, 2026.
Transparency log