Skip to content

Release 0.7.0: fast transcription, chat, web search, prod compatibility - #17

Merged
dawidope merged 14 commits into
mainfrom
release-0.7.0
Nov 30, 2026
Merged

dawidope merged 14 commits into
mainfrom
release-0.7.0

Conversation

@dawidope

Copy link
Copy Markdown
Member

Release 0.7.0. It adds fast transcription, chat (LLMs), web search, compatibility with the current production API, and realtime that works out of the box.

Fast transcription of short audio clips

  • client.transcription.transcribe_sync() (sync and async clients) handles voice notes, commands and short clips. The transcript comes back in the same HTTP response, with no job, polling or webhook.
    • The result is a typed SyncTranscriptionResult: transcription, the detected language, duration, the charged price and, on request, segments (with words at ts_level="word").
    • transcribe_sync_price() quotes it from the file or from duration_seconds.
    • The model defaults to FluidSpeechPro.
  • Limits: clip limits stay with the API (currently up to 60 s, see https://docs.deapi.ai). A clip that is too long keeps the API's message, plus a pointer to the regular create().
  • Access: the feature is in limited availability. Accounts without access get a 404 or a 422 on model, raised as SyncTranscriptionUnavailableError. It is also a NotFoundError / ValidationError, so existing handlers keep working.
  • The new example is examples/transcription_sync.py.

Chat (LLMs)

  • client.chat works on the sync and async clients, through deAPI's OpenAI-compatible API (https://oai.deapi.ai/v1) with the same API key.
  • chat.completions.create(model=..., messages=[...], **params) returns a typed ChatCompletion in the OpenAI shape. deAPI's extras are included: usage.cost, the X-DeAPI-Cost header, reasoning_content and reasoning_details. A returned message can be appended to messages as is.
  • stream=True returns a chunk iterator. The SDK asks for the final usage chunk by default, so usage and cost are available.
  • reasoning_effort is typed ("none" … "max").
  • chat.models() lists the chat models with limits, supported parameters and prices.
  • No retries: chat requests are sent once and never retried automatically, because every accepted request is billed.
  • Config and errors:
    • oai_base_url option / DEAPI_OAI_BASE_URL sets the API address.
    • OpenAI-shaped errors map to the SDK's exceptions.
  • The new example is examples/chat.py.

Web search and page contents

  • client.web.search() and client.web.contents(), plus free quotes search_price() and contents_price(). Results come back in the response.
  • A page that cannot be read keeps its status and WebPage.reason (for example fetch_failed), and is not charged.
  • The feature is in limited availability. Accounts without access get a 404, raised as WebSearchUnavailableError, which is a NotFoundError.

Current production API

  • Retired models: a request naming a retired model raises ModelRetiredError (HTTP 410 model_retired), with retired_at and replacement. The docs and examples use current models only.
  • Job prices: JobResult.price_amount and price_is_estimated give the charge of a finished job. Music is billed by the length actually generated, so compose_price() is documented as a quote.
  • Webhooks: the docs say a refund is booked before job.failed is sent.

Fixed: realtime without manual settings

  • Before: since 0.6.0, client.realtime() reads its connection settings from GET /websocket. Where that answers 404, connect() failed unless ws_url and app_key were set by hand.
  • Now: on a 404, a missing ws_url / app_key is filled with the production WebSocket server and its public app key. Only the Client ID is needed.
    • The built-in server is used only against the production API.
    • Explicit, environment and discovered settings always win.
    • Without a Client ID, a clear RealtimeError names what to pass.

Breaking changes

A 410 with code: "model_retired" used to be a plain DeapiError. It is now ModelRetiredError, a subclass, so except DeapiError still catches it. Everything else is additive.

Checks

  • ruff check src tests examples passes.
  • mypy src tests/fake_pusher.py tests/test_request_files.py passes.
  • pytest -m "not integration": 796 passed on Python 3.11 and 3.13, in Docker.
  • Live against the production API:
    • transcribe_sync() (transcript, language, price);
    • chat with streaming and cost;
    • web search and contents;
    • realtime with the fallback, connecting and following a job.

Version 0.7.0 is set in pyproject.toml, _version.py and the CHANGELOG. After merging, publish a GitHub Release v0.7.0 to upload to PyPI (the pypi environment waits for approval).

🤖 Generated with Claude Code

dawidope and others added 14 commits November 29, 2026 17:47
client.transcription.transcribe_sync() (sync and async clients) uploads a
short audio file (up to 60 s) to POST /audio/transcriptions/sync and returns
the transcript from the response as SyncTranscriptionResult: transcription,
detected language, duration, price and, with timestamps, segments with
optional words. There is no job to poll. The model defaults to FluidSpeechPro;
ts_level implies include_ts, as in create().

transcribe_sync_price() quotes it from the file or from duration_seconds,
always as multipart.

Synchronous transcription is in limited availability. A 404, or a 422 on
model, is raised as SyncTranscriptionUnavailableError, which is also a
NotFoundError or a ValidationError so existing handlers keep catching it.
Other errors (a clip over 60 s, balance, rate limit) are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WhisperLargeV3 is retired. The examples' file-upload and price calls now
use WhisperLargeV3Ct2, the plain-text demo in examples/transcription.py is
dropped, and the docs describe plain-text models without naming the retired
one. Tests that use the name only as an arbitrary model string are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docstrings, README, API reference, CHANGELOG and the example now open with
the limit: up to 60 s and 16 MiB per file, for voice notes, commands and
short clips, with create() for anything longer.

Limits are checked locally where it is cheap: a source_file over 16 MiB,
or a quote for duration_seconds over 60, raises ValueError before anything
is sent. A 422 on source_file (e.g. a clip over 60 s) stays a
ValidationError with the API's errors and body, and its message now also
points to create().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The limits can change on the API side, so the SDK no longer hardcodes
them: the local 16 MiB and 60 s checks, their constants and the numbers
in docstrings, the hint text and the example are gone. A 422 on
source_file still passes the API's message (which states the current
limit) through and adds a pointer to create() for longer audio.

The README and API reference describe it as fast transcription for short
audio clips, "currently up to 60 seconds", with a link to the deAPI docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GET /websocket answers 404 where the API does not provide realtime
settings, and since 0.6.0 connect() then failed with NotFoundError unless
ws_url and app_key were set by hand. On a 404, connect() now fills the
missing ws_url / app_key with the built-in production WebSocket server
and its public app key (only for the production base_url), so only the
Client ID is needed (client_id or DEAPI_CLIENT_ID). Without it, or for
another base_url without ws_url / app_key, connect() raises RealtimeError
naming the settings to pass (status_code 404, the NotFoundError as its
cause) and does not connect. Other HTTP errors from discovery propagate
as before; explicit, environment and discovered settings still win.

Tests cover the fallback with the fake Pusher server (sync and async),
the missing Client ID, a non-production base_url, discovered settings
winning and other HTTP errors. README, API reference, .env.example, the
realtime example and CHANGELOG (Unreleased, Fixed) are updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nanonets_Ocr_S_F16, AceStep_1_5_Turbo and WhisperLargeV3 are no longer in
the model catalogue. The README OCR example and the OCR tests now use
LightOnOcr_3_4B_Q8, the music tests AceStep_1_5_XL_Turbo_INT8 and the
transcription payload test WhisperLargeV3Ct2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
client.chat.completions.create(model=..., messages=[...], **params) posts
to /chat/completions on oai_base_url (default https://oai.deapi.ai/v1,
env DEAPI_OAI_BASE_URL) with the same API key, on the sync and async
clients. It returns a ChatCompletion in the OpenAI shape with deAPI's
extras: usage.cost, the X-DeAPI-Cost header (header_cost),
reasoning_content and reasoning_details. Other Chat Completions parameters
pass through; a message returned by the SDK can be appended to messages
as is, so reasoning_details go back in the next turn.

stream=True returns a ChatCompletionStream (AsyncChatCompletionStream) of
ChatCompletionChunk parsed from SSE; the final usage chunk sets usage and
cost. Errors are raised before the first chunk; an error event inside the
stream raises DeapiError.

client.chat.models() lists the /models entries that have pricing, as
ChatModel with per-1M-token price helpers.

The HTTP clients gain request_response() (to read headers), open_stream()
and a per-request timeout, all on the existing retry policy: a POST is
never resent after a timeout or a 5xx. OpenAI-shaped error bodies map to
the existing exceptions; a 400 is a ValidationError and an out-of-credit
error (insufficient_quota / insufficient_balance) an
InsufficientBalanceError that is not retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The OpenAI-compatible API bills every chat request it accepts and does
not honour an Idempotency-Key, so chat completions (streamed or not) are
now sent exactly once: no automatic retry after a 429 or a connection
error either. The HTTP clients' request_response() and open_stream() take
retry=False for this; chat.models() is a GET and keeps the usual policy.

reasoning_effort is an explicit parameter typed as ReasoningEffort
("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"), with
other strings still accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With stream=True and no stream_options, chat.completions.create() now
sends stream_options={"include_usage": true}, so a stream's usage and
cost are available without extra arguments. An explicit stream_options
(e.g. {"include_usage": false}) is sent as given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- client.web.search() / contents() (sync and async) with search_price()
  and contents_price(): synchronous calls whose results come back in the
  response as WebResults (request_id, cost, results of WebPage). Text,
  excerpts and summary options take True, a max_length / query, or the
  API's object; for search they are sent as "include". Web search is in
  limited availability: a 404 is raised as WebSearchUnavailableError (a
  NotFoundError). Like other POSTs, a web call is retried after a 429 (a
  refused call is not charged) and never resent after a timeout or a 5xx.
- A 410 whose code is model_retired (or whose body has retired_at) raises
  ModelRetiredError with the API's message, retired_at and replacement;
  any other 410 stays a DeapiError. Not retried.
- JobResult.price_amount / price_is_estimated read the job's charge from
  price. Text-to-music is billed by the length actually generated, so
  compose_price() is documented as a quote for the requested duration.
- Webhooks: a refund is booked before job.failed is sent, so refunded
  reports it; docs and the WebhookEventData docstring say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The API adds "reason" (e.g. "fetch_failed") to some web contents results
with status "unknown"; it is now a typed field instead of an extra.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	CHANGELOG.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dawidope
dawidope merged commit 05c8a29 into main Nov 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant