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://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.1.8.tar.gz (27.6 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.1.8-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cortex_suite_sdk-1.1.8.tar.gz
  • Upload date:
  • Size: 27.6 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.1.8.tar.gz
Algorithm Hash digest
SHA256 675b6b3e06164eb2bdd92958cc2150f2adb90e04e7975cc46c29c7e9a00dbc8a
MD5 ea1b58904ea67e9428850d90beff5939
BLAKE2b-256 bdbadce68a6caf70660b90320bb05459a0a03954bbef7cdcc51b92c6395925f5

See more details on using hashes here.

Provenance

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

Publisher: release.yml on Cortex-Suite-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.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for cortex_suite_sdk-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b9139fd737c21ee6b1e9a777d97d9b978a8abb40978437c060bf36453b09e638
MD5 ee896e3e9d36213e42d980b3804d6d5a
BLAKE2b-256 0136c60821fd99dbc35c97a5504089cb72bed08ed3f460c72da8ea872636a782

See more details on using hashes here.

Provenance

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

Publisher: release.yml on Cortex-Suite-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