Metadata-Version: 2.4
Name: sydear
Version: 0.1.0
Summary: Sydear API — chat, audio, image, music, video
Author-email: Sydear <ops@sydear.space>
License-Expression: MIT
Project-URL: Homepage, https://sydear.space
Project-URL: Documentation, https://docs.sydear.space
Project-URL: Repository, https://github.com/Techfrontiers/sydear-python
Project-URL: Status, https://status.sydear.space
Keywords: sydear,ai,llm,chat,audio,image,video
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.24.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
Dynamic: license-file

# sydear

Official Python SDK for the [Sydear API](https://docs.sydear.space).

Chat, audio (TTS / STT), image generation, music, video — wrapped in a
clean Python interface with both sync and async clients.

## Install

```bash
pip install sydear
```

## Quick start

```python
from sydear import Sydear

client = Sydear(api_key="...")  # or set SYDEAR_API_KEY env var

# Chat completion
resp = client.chat.create(
    model="sydear-auto",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp["choices"][0]["message"]["content"])

# Streaming chat
for chunk in client.chat.stream(
    model="sydear-auto",
    messages=[{"role": "user", "content": "Tell me a story"}],
):
    delta = chunk["choices"][0]["delta"].get("content", "")
    print(delta, end="", flush=True)

# Text-to-Speech
audio = client.audio.speech(input="Hello world", model="sydear-echo")
open("hello.mp3", "wb").write(audio)

# Speech-to-Text
result = client.audio.transcriptions(
    file="recording.mp3",
    model="sydear-stt-1",
    language="th",
)
print(result["text"])

# Image generation
img = client.images.generate(prompt="a cute cat", n=1)
print(img["data"][0]["url"])

# Music generation
track = client.music.generate(prompt="upbeat indie pop", lyrics="...")

# Video generation
clip = client.videos.generate(prompt="a cat playing piano")

# Usage / balance
print(client.usage.credits())
print(client.usage.today())

# List models
for m in client.models.list()["data"]:
    print(m["id"])
```

## Async

```python
from sydear import Sydear
import asyncio

client = Sydear(api_key="...", async_=True)

async def main():
    resp = await client.chat.acreate(
        model="sydear-auto",
        messages=[{"role": "user", "content": "Hi"}],
    )
    print(resp["choices"][0]["message"]["content"])

asyncio.run(main())
```

## Aliases

| Alias | Purpose |
|---|---|
| `sydear-auto` | Smart router — picks best alias automatically (recommended) |
| `sydear-singularity` | Flagship reasoning |
| `sydear-quasar` | High-performance balanced |
| `sydear-pulsar` | Legacy balanced |
| `sydear-orbit` | Economy tier |
| `sydear-comet` | Ultra-fast high-speed |
| `sydear-meteor` | Fast lightweight |
| `sydear-galaxy` | Image generation |
| `sydear-echo` | Text-to-Speech |
| `sydear-supernova` | Music generation |
| `sydear-video-v1` | Video generation |
| `sydear-stt-1` | Speech-to-Text |

## Errors

All exceptions inherit from `sydear.SydearError`:

| Exception | HTTP | Cause |
|---|---|---|
| `AuthenticationError` | 401/403 | Invalid or missing API key |
| `InvalidRequestError` | 400 | Malformed request |
| `InsufficientSPUError` | 402 | SPU balance ≤ 0 |
| `RateLimitError` | 429 | Rate limit (has `.retry_after`) |
| `APIError` | other 4xx/5xx | Other server errors (has `.status`, `.body`) |

```python
from sydear import Sydear, RateLimitError

client = Sydear(api_key="...")
try:
    client.chat.create(model="sydear-auto", messages=[...])
except RateLimitError as e:
    if e.retry_after:
        time.sleep(e.retry_after)
        # retry...
```

## Requirements

- Python 3.8+
- `httpx>=0.24`

## Links

- Docs: https://docs.sydear.space
- Status: https://status.sydear.space
- Repo: https://github.com/Techfrontiers/sydear-python
- Issues: https://github.com/Techfrontiers/sydear-python/issues

## License

MIT
