Skip to main content

yuppie-siliconflow

硅基流动(SiliconFlow)API 客户端库:文生图 / 图生图。

纯客户端库,不含 MCP、不依赖 mcp 包,可在任意 Python 项目中直接使用。

安装

uv pip install yuppie-siliconflow
# 或
pip install yuppie-siliconflow

快速开始

import asyncio

from yuppie_siliconflow import SiliconFlowClient


async def main() -> None:
    client = SiliconFlowClient.from_env()  # 读取 SILICONFLOW_API_KEY
    result = await client.generate_image(
        prompt="a cozy reading nook, warm afternoon light, illustration",
        resolution="1024x1024",
    )
    print(result["images"][0]["url"])
    await client.aclose()


asyncio.run(main())

环境变量

变量 必填 说明
SILICONFLOW_API_KEY ✅ 硅基流动 API Key
SILICONFLOW_BASE_URL 默认 https://api.siliconflow.com(国内站改 https://api.siliconflow.cn)
SILICONFLOW_MODEL 默认文生图模型,默认 Tongyi-MAI/Z-Image-Turbo
SILICONFLOW_IMAGE_DIR 图片保存目录,不设则只回传在线 URL

也可不依赖环境变量,直接构造:SiliconFlowClient(SiliconFlowConfig(api_key="sk-..."))。

能力

  • generate_image(...) — 文生图(支持分辨率、宽高比、种子、负面提示词、批量)
  • edit_image(...) — 图生图 / 图像编辑

注意事项

FLUX.1-schnell / FLUX.1-dev 在硅基流动返回的 S3 预签名 URL 签名无效,生成后立即下载也会 403 SignatureDoesNotMatch。默认模型因此改用 Tongyi-MAI/Z-Image-Turbo;如需使用这两个模型, 建议开启本地保存(SILICONFLOW_IMAGE_DIR)以外的备用方案,或改用其它 FLUX 型号。

Metadata

Release files for yuppie-siliconflow 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yuppie-siliconflow 0.2.0
File Size Uploaded
yuppie_siliconflow-0.2.0.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yuppie-siliconflow 0.2.0
File Interpreter ABI Platform
yuppie_siliconflow-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / yuppie_siliconflow-0.2.0.tar.gz

Download URL yuppie_siliconflow-0.2.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
30617a91f51f7c142829c3601f601319232827f307ec724a167d05b776916528
BLAKE2b-256 checksum
How to use checksums
f28aba69ee3c543d66f7d2ad756f5c66c113e84402e38f24163bdddf52973494
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / yuppie_siliconflow-0.2.0-py3-none-any.whl

Download URL yuppie_siliconflow-0.2.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
672a0b5cc992d418afdcbf6497dd60f85838466864587c4f57004b9c046da076
BLAKE2b-256 checksum
How to use checksums
4bda3e6490fdf35f841bba8fd5dae2a3a1e2f636e2d753a00cd3813ee4c3d78c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page