Skip to main content

Sydear API — chat, audio, image, music, video

Project description

sydear

Official Python SDK for the Sydear API.

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

Install

pip install sydear

Quick start

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

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)
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

License

MIT

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

sydear-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

sydear-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file sydear-0.1.0.tar.gz.

File metadata

  • Download URL: sydear-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sydear-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49d4bd7d717c20d3182987cfb164be3b41bd09bb7d0cdd7f0a50867cad53727d
MD5 39ede0139128cfd2d8de87ac8ba541ce
BLAKE2b-256 ba88bfcc5cd33b6864b7d4a953e4bf6ff380c7f5ea6489eedc3b9c3051e1e0ad

See more details on using hashes here.

File details

Details for the file sydear-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sydear-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sydear-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e61bdcfc645a51bad04532d4b5104fbb254e2e64952e5396a5415bc56c1a92c
MD5 2e7a948240aa7cea7227d6031e945e56
BLAKE2b-256 4cfb070eba38165f088e2e78f6e80dd796366cec053ef806374f2ce9bb73d3e7

See more details on using hashes here.

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