Metadata-Version: 2.4
Name: api-sdk
Version: 0.3.0
Summary: API SDK for image generation and other services
Author-email: Your Name <your.email@example.com>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: elevenlabs>=1.0.0
Requires-Dist: google-genai>=1.56.0
Requires-Dist: numpy>=2.0.0
Requires-Dist: onnxruntime>=1.20.0
Requires-Dist: opencv-python>=4.10.0
Requires-Dist: Pillow>=10.0.0
Requires-Dist: pymatting>=1.1.13
Requires-Dist: rembg>=2.0.60
Requires-Dist: requests>=2.31.0
Requires-Dist: volcengine-python-sdk[ark]>=5.0.42
Requires-Dist: websocket-client>=1.6.0
Provides-Extra: alignment
Requires-Dist: qwen-asr==0.0.6; extra == "alignment"
Requires-Dist: torch==2.8.0; extra == "alignment"
Requires-Dist: torchaudio==2.8.0; extra == "alignment"

# API SDK

A Python SDK for image generation using Google Gemini API.

## Installation

```bash
pip install -e .
```

Or install dependencies directly:

```bash
pip install -r requirements.txt
```

## Configuration

This SDK does not load any `.env` file. Provide credentials via environment variables:

```bash
# Google Gemini
export GOOGLE_API_KEY=your-api-key
# (Optional legacy alias) export GEMINI_API_KEY=your-api-key

# Volcengine Jimeng
export VOLC_ACCESSKEY=...
export VOLC_SECRETKEY=...

# Volcengine Ark Seedream 5.0 Lite
export ARK_API_KEY=...

# TTS providers
export ELEVENLABS_API_KEY=...
export VOLCENGINE_TTS_API_KEY=...
export VOLCENGINE_TTS_APP_ID=...  # optional; set it when your console credentials include one
export FLYTEK_APPID=...
export FLYTEK_APIKey=...
export FLYTEK_APISecret=...
export FLYTEK_URL=wss://tts-api-sg.xf-yun.com/v2/tts
```

## Usage

### As a Python Library

```python
from api_sdk.image_generator import generate_image
from api_sdk import generate_text
from api_sdk import generate_speech, generate_speech_bytes

# Generate an image
output_path = generate_image(
    prompt="A beautiful sunset over mountains",
    output_path="./images/sunset.png"
)
print(f"Image saved to: {output_path}")

# Generate text
text, _ = generate_text(
    prompt="给我一首关于秋天的短诗",
)
print(text)

# Synthesize speech (bytes, no disk I/O)
audio_bytes = generate_speech("你好，世界")  # 默认返回 WAV bytes
Path("./audio").mkdir(parents=True, exist_ok=True)
Path("./audio/hello.wav").write_bytes(audio_bytes)
```

### Using the CLI

Generate an image with a simple prompt:

```bash
python -m api_sdk.cli generate-image "A beautiful sunset over mountains"
```

Generate an image and save to specific location:

```bash
python -m api_sdk.cli generate-image "A cat playing piano" -o ./images/cat_piano.png
```

Use verbose mode for detailed output:

```bash
python -m api_sdk.cli generate-image "Modern architecture" -v
```

No CLI `--api-key` flag is provided; credentials are discovered automatically
via environment variables.

After installation with pip, you can also use the command directly:

```bash
# Default image provider is Jimeng (requires VOLC_ACCESSKEY/VOLC_SECRETKEY)
api-sdk generate-image "Your prompt here"

# Or use Gemini explicitly
api-sdk generate-image --provider gemini "Your prompt here"
```

Generate image (Volcengine Jimeng / 即梦，AK/SK):

```bash
export VOLC_ACCESSKEY=...
export VOLC_SECRETKEY=...

# 文生图（当前接入：jimeng_t2i_v40）
api-sdk generate-image --provider jimeng "公共信息墙上的医学文献检索结果页面，冷静权威可信" -o ./images -n jimeng_img

# 可选：尝试指定宽高（是否支持取决于模型；高级参数可用 --extra-config-file 透传）
api-sdk generate-image --provider jimeng "A calm authoritative information dashboard UI" --width 1024 --height 576 -o ./images -n jimeng_16_9
```

Generate image with Seedream 5.0 Lite through Volcengine Ark:

```bash
export ARK_API_KEY=...

# Text-to-image
api-sdk generate-image --provider seedream \
  "1930s mountain road after rain, restrained historical documentary style" \
  --width 2560 --height 1440 -o ./images -n seedream_landscape

# Single or multiple local reference images (up to 14)
api-sdk generate-image --provider seedream \
  "Keep the clothing and landscape style of the references; create a new wide shot" \
  -i ./references/style.png -i ./references/character.png \
  --width 2560 --height 1440 -o ./images -n seedream_referenced
```

Generate video (Gemini Veo):

```bash
api-sdk generate-video "A cinematic shot of a tiny robot walking through a rainy neon city"
api-sdk generate-video "Make it sunrise" -i examples/1.jpg -o ./videos -n sunrise

# With reference images (max 3) + optional types (ASSET / STYLE)
api-sdk generate-video "Keep the same character, new scene" \
  --reference-image examples/1.jpg --reference-type ASSET \
  --reference-image examples/2.jpg --reference-type STYLE \
  -o ./videos -n ref_demo

# Extend an existing video
api-sdk generate-video "Continue the scene with slower camera movement" \
  --extend-video ./videos/demo.mp4 \
  --duration-seconds 8 --resolution 720p -o ./videos -n extended
```

Generate video (Volcengine Jimeng / 即梦，AK/SK):

```bash
# 通过环境变量提供火山引擎 AK/SK
export VOLC_ACCESSKEY=...
export VOLC_SECRETKEY=...

# 文生视频（当前接入：jimeng_t2v_v30）
api-sdk generate-video --provider jimeng "一段冷静、权威的医学文献检索信息墙界面，从加载态过渡到结果总览" \
  --aspect-ratio 16:9 --duration-seconds 5 -o ./videos -n jimeng_demo

# Jimeng 也可直接指定帧数（121=5s，241=10s）
api-sdk generate-video --provider jimeng "A calm authoritative public information panel UI" --frames 241 -o ./videos -n jimeng_10s
```

Generate video (Volcengine Ark Seedance，API Key):

```bash
export ARK_API_KEY=...

# 文生视频；默认使用 Seedance 2.0 标准版
api-sdk generate-video --provider seedance \
  "1930年代山路，克制的历史纪录片质感，镜头缓慢前移" \
  --aspect-ratio 16:9 --resolution 720p --duration-seconds 5 \
  -o ./videos -n seedance_demo

# 首帧/尾帧控制；Fast 模型可显式指定
api-sdk generate-video --provider ark \
  "保持人物与环境一致，只做自然微动和缓慢运镜" \
  --model doubao-seedance-2-0-fast-260128 \
  --image ./frames/start.png --last-frame ./frames/end.png \
  --camera-fixed --duration-seconds 5 \
  -o ./videos -n seedance_keyframes
```

Python 调用使用相同参数；Ark 特有开关通过 `extra_config` 传入：

```python
from api_sdk import generate_video

video_path, description_path = generate_video(
    "subtle documentary motion",
    provider="seedance",
    input_image="./frames/start.png",
    duration_seconds=5,
    extra_config={
        "camera_fixed": True,
        "watermark": False,
        "return_last_frame": False,
    },
)
```

Seedance 当前每个调用生成一个视频，时长支持 4–15 秒。尾帧必须与首帧同时提供。
`reference_images`、视频续写和 Veo 专属配置会直接报错，不会静默忽略。

Generate text:

```bash
api-sdk generate-text "给我一段关于海风的散文"
api-sdk --json generate-text "Summarize: ..." --model gemini-2.5-pro --max-tokens 512

# Use Codex as text provider (non-interactive, safe sandbox)
api-sdk generate-text "写一首关于红豆的诗歌（中文）" --provider codex
python -m api_sdk.cli generate-text --provider codex "写一句关于红豆的短句（中文）"
```

Structured Output (Gemini):

```bash
# Pass a JSON schema to enforce structured JSON output.
api-sdk generate-text "Generate a recipe for butter cookies" --provider gemini --response-schema-file ./examples/recipe.schema.json
```

Structured Output (Codex):

```bash
api-sdk generate-text "Extract project metadata" --provider codex --response-schema-file ./examples/recipe.schema.json
```

Models:
- Default image provider: `jimeng`
- Default image model (Jimeng req_key): `jimeng_t2i_v40`
- Seedream/Ark image model: `doubao-seedream-5-0-260128`
- Gemini image default model: `gemini-3.1-flash-image-preview` (when `--provider gemini`)
- You can also pass a different model explicitly, e.g.: `--model gemini-2.5-flash-image` or `--model jimeng_t2i_v40`
- Default video model (Gemini Veo): `veo-3.1-generate-preview`
- Default video model (Jimeng req_key): `jimeng_t2v_v30`
- Default video model (Ark Seedance): `doubao-seedance-2-0-260128`
- Ark Seedance Fast model: `doubao-seedance-2-0-fast-260128`

Global flags:
- `--json` Emit machine-readable JSON to stdout (for pipelines)
- `-v/--verbose` Verbose logs (DEBUG)
- `-q/--quiet` Suppress non-error logs
- `--no-color` Disable decorative icons/emojis

Example JSON output:

```bash
api-sdk --json detect-objects examples/1.jpg "Find animals"
# {"ok":true,"command":"detect-objects","output_path":"images/1_detected.jpg","objects":[...],"model":"gemini-2.0-flash-exp"}
```

Shell wrapper:
- A thin shell launcher is available at `bin/api-sdk` (executes `python -m api_sdk.cli "$@"`).
  You can run `chmod +x bin/api-sdk` and add it to your PATH if desired.

### Text-to-Speech (TTS)

支持提供方：Google Gemini TTS（默认，Algieba）、火山引擎豆包语音、iFlytek、ElevenLabs。

火山引擎豆包语音 V3（默认使用 2.0 音色 `zh_female_vv_uranus_bigtts`，24 kHz）：

```bash
export VOLCENGINE_TTS_API_KEY=...
# 若当前控制台凭据包含 APP ID，则一并设置；SDK 会自动发送。
export VOLCENGINE_TTS_APP_ID=...

api-sdk synthesize-speech "先完成最小的一步，我们再决定下一步。" \
  --provider volcengine --format mp3 -o ./audio/coach.mp3
```

可通过 `--voice` 或 `VOLCENGINE_TTS_VOICE` 更换音色。高级配置可使用：

- `VOLCENGINE_TTS_RESOURCE_ID`：默认 `seed-tts-2.0`；
- `VOLCENGINE_TTS_ENDPOINT`：默认 V3 SSE 单向流式端点；
- `VOLCENGINE_BIDIRECTIONAL_TTS_ENDPOINT`：默认 V3 双向流式 WebSocket 端点；
- `VOLCENGINE_TTS_UID`：可选的非敏感业务用户标识；
- `--speed`：语速 `-50...100`；
- `--volume`：响度 `-50...100`；
- `--pitch`：音调 `-12...12`。

单向 SSE 的 `synthesize_speech_volcengine_bytes` 与 `create_volcengine_streaming_tts_session` 支持 `explicit_language`：`"zh-cn"` 表示中文为主且支持中英混读，`"en"` 表示英语；不传时保留供应商默认行为。该值写入 `req_params.additions`，不会根据音色名称自动推断。

需要边接收边播放时，可直接消费 V3 SSE 返回的 24 kHz、16-bit、单声道 PCM 分片；调用 `close()` 可停止并释放当前响应：

```python
from api_sdk import create_volcengine_streaming_tts_session

session = create_volcengine_streaming_tts_session(text="这是最终答复。")
try:
    for pcm_s16le_chunk in session.audio_chunks():
        play_or_forward(pcm_s16le_chunk)
finally:
    session.close()
```

`audio_chunks()` 只能消费一次，并要求服务端发出成功完成帧；完整 WAV/MP3 调用仍使用 `synthesize_speech_volcengine_bytes()`。

LLM 边生成文字、边合成语音时使用 V3 双向会话。一个逻辑答复只建立一次 WebSocket，后续稳定文本段通过 `append_text()` 追加到同一 session；`finish()` 表示文本输入结束，`close()` 用于取消：

```python
from api_sdk import create_volcengine_bidirectional_tts_session

session = create_volcengine_bidirectional_tts_session(uid="my-agent-chat")
try:
    session.append_text("第一段。")
    session.append_text("第二段仍在生成。")
    session.finish()
    for pcm_s16le_chunk in session.audio_chunks():
        play_or_forward(pcm_s16le_chunk)
finally:
    session.close()
```

双向会话默认连接 `wss://openspeech.bytedance.com/api/v3/tts/bidirection`，`provider_log_id` 暴露握手返回的 `X-Tt-Logid` 供无正文诊断。单向 SSE 要求一次性输入完整文本，不能按句段重复建连来实现 LLM 实时朗读。接口选择以火山官方 [语音合成大模型 API 列表](https://www.volcengine.com/docs/6561/2228192?lang=zh) 和 [V3 双向流式文档](https://www.volcengine.com/docs/6561/2532486?lang=zh) 为准。

ElevenLabs（需要在环境变量里配置 `ELEVENLABS_API_KEY`；voice_id 默认 `DowyQ68vDpgFYdWVGjc3`，也可通过 `ELEVENLABS_VOICE_ID` 或 CLI `--voice` 覆盖）：

```bash
export ELEVENLABS_API_KEY=...
export ELEVENLABS_VOICE_ID=JBFqnCBsd6RMkjVDRZzb

api-sdk synthesize-speech "The first move is what sets everything in motion." \
  --provider elevenlabs --format mp3 --model eleven_multilingual_v2 -o ./audio/eleven.mp3
```

合成中文语音示例（默认输出 WAV 16k 单声道）：

```bash
# Gemini（默认，Algieba）
api-sdk synthesize-speech "你好，世界" -o ./audio/hello_google.wav --format mp3

# 指定模型（默认已是 gemini-2.5-pro-preview-tts）：
api-sdk synthesize-speech "你好，世界" --provider gemini --model gemini-2.5-pro-preview-tts -o ./audio/hello2.mp3 --format mp3

# 生成 MP3（Google 侧支持）：
api-sdk synthesize-speech "Hello, this is a demo." --provider algieba --model gemini-2.5-pro-tts --format mp3 -o ./audio/demo.mp3
```

说明：
- Google Gemini TTS（Algieba）默认输出可直接为 MP3（--format mp3）。可选传入 `--voice`（可用值因模型/地区不同）。
- iFlytek 默认音色（voice/vcn）为 `x_xiaoyang_story`，也可以通过 `--voice` 自行指定。

自定义参数（音色、格式、采样率）：

```bash
api-sdk synthesize-speech "欢迎使用语音合成" \
  --voice x_John \
  --format wav \
  --sample-rate 16000 \
  -o ./audio/welcome.wav
```

环境变量:
- `FLYTEK_APPID`
- `FLYTEK_APIKey`
- `FLYTEK_APISecret`
- `FLYTEK_URL`（可选，覆盖默认端点）
- `VOLCENGINE_TTS_API_KEY`
- `VOLCENGINE_TTS_APP_ID`（可选）
- `VOLCENGINE_TTS_VOICE`（可选）
- `VOLCENGINE_TTS_RESOURCE_ID`（可选）
- `VOLCENGINE_TTS_ENDPOINT`（可选）
- `VOLCENGINE_BIDIRECTIONAL_TTS_ENDPOINT`（可选）
- `GEMINI_API_KEY`（可选；若未设置则走 Google 默认凭据/ADC）

认证说明（Google）：
- 本地开发可直接设置 `GEMINI_API_KEY`（无需交互），或运行 `gcloud auth application-default login` 使用 ADC（需要一次交互登录）。
- 生产环境推荐使用服务账号，通过 `GOOGLE_APPLICATION_CREDENTIALS` 指向 JSON key，或使用云环境的工作负载身份（无人工交互）。

Provider 别名：`google`、`gemini`、`algieba` 均指向 Google Gemini TTS；`volcengine`、`doubao` 均指向火山引擎豆包语音。默认 provider 为 `algieba`。

注意：可用的音色代码（`--voice`/vcn）因账号而异，请根据你在讯飞控制台开通的音色填写。

### 本地旁白强制对齐（音频驱动画面）

`LocalForcedAligner` 接收**已经确定的音频 + 自然意群原文**，使用本地
`Qwen/Qwen3-ForcedAligner-0.6B` 返回字词时间轴。它不重新识别/改写旁白，
不调用 TTS，不剪静音、不变速，也不写回音频。无需 API Key；首次运行需要
下载模型，之后可使用本地模型目录离线推理。模型版本默认固定到
`c7cbfc2048c462b0d63a45797104fc9db3ad62b7`。
默认模型缓存在 `~/.cache/api_sdk/models/Qwen3-ForcedAligner-0.6B/<revision>/`，
缓存完整时直接从本机加载；权重约 1.84 GB，另需安装推理依赖。

安装：建议在独立 Python 3.11 环境中安装可选依赖，并确保 `ffmpeg` 在 PATH 中。
普通 SDK 导入和其他供应商调用不会加载 PyTorch 或对齐模型。

```bash
python3.11 -m venv .venv-alignment
source .venv-alignment/bin/activate
python -m pip install -e '.[alignment]'
```

```python
import json
from pathlib import Path
from api_sdk import LocalForcedAligner

# 使用下载好的本地目录时传 model="/path/to/model"；默认首次下载公开权重。
aligner = LocalForcedAligner(device="cpu")
timeline = aligner.align(
    "narration.wav",
    "随机森林汇总多棵树的判断，XGBoost 累加多棵树的输出。",
)
cue = timeline.locate("XGBoost")
print(cue.start_ms, cue.end_ms)
Path("narration.timeline.json").write_text(
    json.dumps(timeline.to_dict(), ensure_ascii=False, indent=2), encoding="utf-8"
)
# 批量自然意群重复使用 aligner.align(...)，避免重复加载模型。
```

命令行：

```bash
api-sdk align-audio narration.wav --text-file narration.txt -o narration.timeline.json
# 完全离线：指定已下载的本地目录
api-sdk align-audio narration.wav --text-file narration.txt --model /path/to/model -o narration.timeline.json
```

时间轴约定：

- `words` 包含 `text`、`spoken_text`、`start_char`、`end_char`、`start_ms`、`end_ms`。
  字符位置是 Python 的 `[start_char:end_char]` 索引，中文通常逐字、英文按词；
  不为标点单独制造时间戳，也不把一个英文词的时长平均分配到各字母。
- 所有毫秒时间相对于该音频起点，保留片头静音；视频绝对触发时间为
  `音频在视频中的起点 + start_ms + 有意设计的视觉偏移`。
- `locate("关键词", occurrence=2)` 定位原稿里第二次出现的关键词；必须覆盖完整对齐单元。
- 返回原始音频 `audio_sha256`、时长和模型信息，便于防止换音频后误用旧时间轴。
- 模型输出属于估计值，`review_required=True`，没有伪造的置信度。零时长单元写入
  `warnings`；词数/文本不一致、非有限值、倒序、越界等结果直接失败，不静默补时间。
- `timestamp_resolution_ms` 记录模型原始时间刻度；当前固定模型为 **80 ms**。
  这不是误差上限，也不是毫秒级或逐帧准确度保证，模型后处理还可能插值。
- 当前适配器支持 `Chinese`（默认，含英文术语）和 `English`；单次音频上限 300 秒。
  推荐按自然意群处理短音频。没有匹配原稿的音频不能依靠对齐结果证明内容正确。

SSML 与发音规则：合成时继续使用 SSML；对齐时传原文，不能把 XML 标签直接传给模型。
如实际读法与写法不同，可以显式提供 `spoken_forms={"2021": "二零二一"}`（仅当录音
确实如此朗读）。对齐用展开后的读法，输出映射回原文 `2021` 的整体时间范围。
CLI 对应 `--spoken-forms spoken-forms.json`。音素标签不自动转换成读音文本。

模型与方法来源：[Qwen3 ForcedAligner 官方说明](https://github.com/QwenLM/Qwen3-ASR#forcedaligner-usage)。
模型文件与推理依赖比 `fa-zh` 更大；选择 Qwen 是为了验证中英混读和专业术语，
不能据此承诺所有关键词都精确到毫秒。关键动作仍应抽听校准。

### 录音文件语音识别

#### 已录制文件转写

统一的录音文件入口接受本地路径或 bytes，默认路由到火山 Seed ASR 2.0 标准版，并返回带时间位置、说话人与实际 provider/model/request ID 的规范结果：

```python
from api_sdk import transcribe_audio_file

result = transcribe_audio_file(
    "lecture.m4a",
    language="zh-CN",
    enable_speaker_labels=True,
    context="科创企业 BP 与疾病机制知识图谱",
)
print(result.text)
for segment in result.segments:
    print(segment.start_ms, segment.end_ms, segment.speaker, segment.text)
```

bytes 输入需要显式传 `audio_format`。默认 provider 可由 `AUDIO_TRANSCRIPTION_PROVIDER` 覆盖；consumer 测试可以注册 `DeterministicAudioTranscriptionProvider`，不需要访问真实供应商。火山 adapter 同时暴露 `submit()`、`query()` 和 `wait()`，用于需要自行持久化长任务状态的 host：

```python
from api_sdk import AudioTranscriptionOptions, VolcengineFileASRClient

client = VolcengineFileASRClient()
options = AudioTranscriptionOptions(timeout_seconds=600, poll_interval_seconds=1)
task = client.submit(audio_bytes, audio_format="m4a", options=options)
result = client.wait(task, timeout_seconds=600, poll_interval_seconds=1)
```

推荐配置：

- `VOLCENGINE_ASR_API_KEY`：新版豆包语音控制台 API Key；
- `VOLCENGINE_FILE_ASR_RESOURCE_ID`：默认 `volc.seedasr.auc`；
- `VOLCENGINE_FILE_ASR_SUBMIT_ENDPOINT`、`VOLCENGINE_FILE_ASR_QUERY_ENDPOINT`：仅在代理或测试环境覆盖；
- 旧控制台可改用 `VOLCENGINE_ASR_APP_ID` 与 `VOLCENGINE_ASR_ACCESS_KEY`。

兼容已有本地环境时也会读取 `VOLC_API_KEY` 与 `APP_ID`，新部署应使用上面的 `VOLCENGINE_*` 名称。SDK 返回供应商原始 JSON 供 host 受控持久化，但不会自行写音频、转写正文或密钥。

火山标准版使用 `submit → query`，资源 ID 为 `volc.seedasr.auc`：
[录音文件识别标准版 HTTP](https://www.volcengine.com/docs/6561/1354867?lang=zh)。

#### 双向流式转写

火山 Seed-ASR 2.0 优化双向流式接口支持实时发送 PCM 并接收不断修订的识别全文。默认使用小时版资源 `volc.seedasr.sauc.duration`：

```python
from api_sdk import create_volcengine_streaming_asr_session

session = create_volcengine_streaming_asr_session(
    api_key="...",  # 也可使用下述环境变量
    sample_rate=16000,
    channels=1,
    bits_per_sample=16,
)
try:
    for result in session.send_audio(pcm_s16le_chunk):
        print(result.text, result.is_final)
    final_results = session.finish()
finally:
    session.close()
```

每个音频 chunk 必须是 16 kHz、16-bit、单声道 little-endian PCM；`send_audio()` 在同步 WebSocket 写入成功后返回，并顺便取走独立接收循环已经得到的结果，不等待该 chunk 对应的识别响应。火山在静音或尚未形成新假设时可能不返回结果帧，这不表示音频发送失败；`text` 是全文 replacement，不应直接追加，尚未到达的结果由后续 `send_audio()` 或 `finish()` 收口。调用方必须在 SDK 外使用有界待发队列和发送超时，不能把稀疏结果误作逐包 ACK。默认请求开启 `enable_ddc=true` 语义顺滑和 `enable_nonstream=true` 二遍识别，默认 endpoint 为 `wss://openspeech.bytedance.com/api/v3/sauc/bigmodel_async`。会话的 `provider_log_id` 暴露握手响应 `X-Tt-Logid` 供日志关联，但不保存音频或转写正文。可选配置：

- `VOLCENGINE_STREAMING_ASR_RESOURCE_ID`：默认 `volc.seedasr.sauc.duration`；
- `VOLCENGINE_STREAMING_ASR_ENDPOINT`：覆盖流式 WebSocket endpoint。

协议参数与分包要求以火山引擎官方文档为准：
[双向流式语音识别 WebSocket](https://www.volcengine.com/docs/6561/2630027?lang=zh)、
[大模型流式语音识别 API](https://www.volcengine.com/docs/6561/1354869?lang=zh)。

## API Reference

### `generate_image()`

Generate an image based on a text prompt.

**Parameters:**
- `prompt` (str): Text prompt for image generation
- `output_path` (str, optional): Path where the generated image will be saved
- `provider` (str, optional): Image provider (`jimeng` by default, or `gemini`)
- `api_key` (str, optional): Google Gemini API key (Gemini only)
- `model` (str, optional): Model to use for generation

**Returns:**
- `(image_path, description_path)`: Paths to the saved image and optional description markdown

### `ImageGenerator` Class

A wrapper class for image generation (Gemini or Volcengine Jimeng / 即梦).

```python
from api_sdk.image_generator import ImageGenerator

generator = ImageGenerator(api_key="your-api-key", provider="gemini")
image_path, description_path = generator.generate_image(
    prompt="Your prompt",
    output_path="output.png"
)
```

### Volcengine SSML pronunciation

The V3 SSE helpers `synthesize_speech_volcengine_bytes` and
`create_volcengine_streaming_tts_session` accept either `text=` or `ssml=`,
exclusively. SSML is sent in `req_params.ssml` and must have a `<speak>` root.
This does not add SSML support to the bidirectional WebSocket API. Voice/tag
compatibility must be checked for the selected voice.

```python
from api_sdk.tts_volcengine import synthesize_speech_volcengine_bytes

audio = synthesize_speech_volcengine_bytes(
    ssml='<speak>每一<phoneme alphabet="py" ph="hang2">行</phoneme></speak>',
    # Credentials come from VOLCENGINE_TTS_API_KEY unless passed explicitly.
)
```
