Official Python SDK for the CygnisAI API
Project description
CygnisAI Python SDK
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.typedmarker (PEP 561) - Public access (closed beta)
Development
pip install -e ".[dev]"
pytest tests/ -v
Licence
MIT — see LICENCE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cygnisai_sdk_python-1.0.0.tar.gz.
File metadata
- Download URL: cygnisai_sdk_python-1.0.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b18a0bb766f2513120ccbd9be051e3b6fc6375b8f3333edcd56e98f423ae8e8
|
|
| MD5 |
e9df2b8ac8e77d9dfdaf63ff8431c2e8
|
|
| BLAKE2b-256 |
189c75da57152dd931a38134e39b09aae7ae57888923a05cecaf6fc87eb5a816
|
File details
Details for the file cygnisai_sdk_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cygnisai_sdk_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c4009d717ed0e3e9e3dce64df06aafc276d9e96d331cfb9aeb325f9e385bb4f
|
|
| MD5 |
a7a563d1d38a1478084283a6b03c3f6f
|
|
| BLAKE2b-256 |
e08b4461b8357975c8ff231ab5b816d050eb8d4f471271cfd57bc430f3bd8c62
|