Cartesia Python SDK v2.0.0 发布
Cartesia | Cartesia Python SDK v2.0.0
Cartesia 发布 Python SDK v2.0.0,围绕主客户端重构开发体验,支持异步客户端、流式输出、WebSocket、自动重试与指数退避,默认超时 60 秒。用户可通过 pip 安装并调用 Cartesia 语音 API。
正文
当前显示原文,中文全文译文尚未就绪。
We are excited to announce the release of v2.0.0 of our Python SDK, polishing the developer experience when using Cartesia’s AI voice capabilities with Python.
This announcement describes SDK v2.0.0. For a setup guide using SDK v4.2.0, see Python text to speech: save audio as a WAV file.
Getting started with Cartesia using Python
Install the Cartesia Python SDK in your project with:
Initialize the SDK and authenticate:
Now, you can start making requests. For example, to generate audio with Cartesia’s text-to-speech model:
For more examples, check out our API Explorer to generate Python code snippets for any of our APIs.
The Python SDK at a glance
Building upon industry established SDK patterns, v2 of our Python SDK delivers a great development experience structured around a primary Cartesia client, which is the entry point for accessing the various API endpoints.
Even more features
Basic Client - Instantiate and use the client with just 24 lines of code; Async Client - The SDK exports an async client alongside standard real-time calls, allowing you to make non-blocking API requests; Streaming - The SDK supports streaming responses and outputs a generator that you can iterate over; WebSocket - Integrate using WebSockets to build realtime, low-latency voice applications; Exception Handling - The API gracefully handles non-success status codes (4xx and 5xx responses); Retries - The SDK is instrumented with automatic retries with exponential backoff; Timeouts - The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level; Custom Client — You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports
What’s next?
We can’t wait to see what you build with the Cartesia Python SDK! Your feedback helps us improve—let us know your thoughts by submitting issues on GitHub.