Skip to main content

Cortex SDK — transport client for Python

Project description

Cortex SDK for Python

Install

pip install cortex-suite-sdk

Quick start

import asyncio

from cortex_sdk import CortexClient


def on_message(msg):
    print(msg["type"], msg["payload"])


async def main():
    client = CortexClient(
        api_key="your-api-key",
        # auth_url="https://auth.cortexsuite.app",  # optional override
        on_message=on_message,
    )
    await client.connect()
    await client.send_message(content="Hello")


asyncio.run(main())

API

See the full API reference. auth_url is optional; if omitted, the SDK uses its default auth base URL.

Error handling

from cortex_sdk import CortexClient, CortexError


def on_message(msg):
    if msg["type"] == "system::error":
        print("Runtime error:", msg["payload"]["code"])
        if msg["payload"].get("fatal"):
            pass  # handle unrecoverable session


client = CortexClient(
    api_key="your-api-key",
    on_message=on_message,
)

try:
    await client.connect()
except CortexError as err:
    if err.code in ("auth_invalid", "auth_refresh_failed"):
        pass  # prompt re-authentication

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

cortex_suite_sdk-1.0.9.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

cortex_suite_sdk-1.0.9-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file cortex_suite_sdk-1.0.9.tar.gz.

File metadata

  • Download URL: cortex_suite_sdk-1.0.9.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cortex_suite_sdk-1.0.9.tar.gz
Algorithm Hash digest
SHA256 e7f11751968f1a03418dab2a9f770e73aa4af275f44d0eb6b7dec7e6282f5302
MD5 4a13c9bdea3e7e3958b5ee3879a0142f
BLAKE2b-256 390e01edf0a1ecd3935024de12eff2ae5900d5bda31c6b9e7ee56084244377c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortex_suite_sdk-1.0.9.tar.gz:

Publisher: publish.yml on Cortex-Suite-App-Team/cortex-sdk

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

File details

Details for the file cortex_suite_sdk-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for cortex_suite_sdk-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 27c825c2ffe4d7f4cd58865d9036b790ff7362aa91f15a3ec351fd78caff6f54
MD5 a59ae1c0bfa29a047a8f44137a077cde
BLAKE2b-256 5fd17c55f10a3e46a10e08265289e13fcb29db358423524594a38ec7471693ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for cortex_suite_sdk-1.0.9-py3-none-any.whl:

Publisher: publish.yml on Cortex-Suite-App-Team/cortex-sdk

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