Skip to main content

CygnisAI Python SDK

GitHub release (latest by date) Python Version License: MIT Tests Status Documentation

The simplest, fastest way to integrate CygnisAI language models into your Python projects.

Note: API access is currently in private beta. Key creation is not yet open to the public.


Installation

pip install git+https://github.com/Simonc44/cygnisai_sdk_python.git

Quick Start

import cygnisai_sdk_python as cygnis

cygnis.configure(api_key="YOUR_API_KEY")

model = cygnis.GenerativeModel("alpha2")
response = model.generate_content("Give me a Python tip.")
print(response.text)

Environment variable

Set CYGNIS_API_KEY and call configure() without arguments:

import cygnisai_sdk_python as cygnis

cygnis.configure()          # reads CYGNIS_API_KEY automatically
model = cygnis.GenerativeModel("alpha2")

Streaming

stream = model.generate_content("Tell me a story.", stream=True)

import asyncio

async def main():
    async for token in stream:
        print(token, end="", flush=True)

asyncio.run(main())

Async usage

import asyncio
import cygnisai_sdk_python as cygnis

cygnis.configure(api_key="YOUR_API_KEY")
model = cygnis.GenerativeModel("alpha2")

async def main():
    response = await model.async_generate_content("Hello!")
    print(response.text)
    print(f"Latency: {response.latency_ms} ms")
    print(f"Tokens used: {response.usage.total_tokens}")

asyncio.run(main())

Low-level client

import asyncio
from cygnisai_sdk_python import CygnisAIClient, ChatRequest, Message

async def main():
    async with CygnisAIClient(api_key="YOUR_KEY") as client:
        request = ChatRequest(
            model="alpha2",
            prompt="What is 2+2?",
            messages=[Message(role="user", content="What is 2+2?")],
        )
        response = await client.chat(request)
        print(response.response)

asyncio.run(main())

Error handling

import cygnisai_sdk_python as cygnis

cygnis.configure(api_key="YOUR_KEY")
model = cygnis.GenerativeModel("alpha2")

try:
    response = model.generate_content("Hello!")
except cygnis.AuthenticationError:
    print("Invalid API key.")
except cygnis.RateLimitError:
    print("Too many requests — slow down.")
except cygnis.ServerError as e:
    print(f"Server error {e.status_code}: {e.message}")
except cygnis.NetworkError:
    print("Could not reach the API.")
except cygnis.CygnisAIError as e:
    print(f"Unexpected SDK error: {e}")

Configuration options

Parameter Type Default Description
api_key str CYGNIS_API_KEY env var Your secret API key
base_url str production URL Override the API base URL
timeout float 30.0 HTTP timeout in seconds
max_retries int 3 Retries on transient errors (429, 5xx)

Available Models

Model Description Status
alpha_v01 Initial test version, lightweight prototyping Stable
alpha1 Balanced, optimised for response speed Stable
alpha2 Most capable, recommended for complex reasoning Stable

Feature Status

  • Simple interface (GenerativeModel)
  • Streaming (stream=True)
  • Async-native client with context manager
  • Automatic retries with exponential backoff
  • Environment-variable API key
  • Typed exceptions (AuthenticationError, RateLimitError, …)
  • Pydantic v2 validation
  • py.typed marker (PEP 561)
  • Public access (closed beta)

Development

pip install -e ".[dev]"
pytest tests/ -v

Licence

MIT — see LICENCE for details.

Metadata

Release files for cygnisai-sdk-python 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cygnisai-sdk-python 1.0.0
File Size Uploaded Provenance Actions
cygnisai_sdk_python-1.0.0.tar.gz 14.3 kB Without provenance Details for cygnisai_sdk_python-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cygnisai-sdk-python 1.0.0
File Interpreter ABI Platform Actions
cygnisai_sdk_python-1.0.0-py3-none-any.whl Python 3 none any Details for cygnisai_sdk_python-1.0.0-py3-none-any.whl

Total release size: 28.1 kB

Release files / cygnisai_sdk_python-1.0.0.tar.gz

Download URL cygnisai_sdk_python-1.0.0.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4b18a0bb766f2513120ccbd9be051e3b6fc6375b8f3333edcd56e98f423ae8e8
BLAKE2b-256 checksum
How to use checksums
189c75da57152dd931a38134e39b09aae7ae57888923a05cecaf6fc87eb5a816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / cygnisai_sdk_python-1.0.0-py3-none-any.whl

Download URL cygnisai_sdk_python-1.0.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c4009d717ed0e3e9e3dce64df06aafc276d9e96d331cfb9aeb325f9e385bb4f
BLAKE2b-256 checksum
How to use checksums
e08b4461b8357975c8ff231ab5b816d050eb8d4f471271cfd57bc430f3bd8c62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for cygnisai-sdk-python 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page