硅基流动api文档
时间: 2025-05-31 17:50:34 浏览: 175
### 硅基流动 API 文档概述
硅基流动提供了一套完整的 API 接口,用于支持多种应用场景下的开发需求。其官方文档可以通过以下方式获取:
#### 1. **访问官网并登录**
首先需要前往硅基流动的官方网站[^3]:
```
https://cloud.siliconflow.cn/
```
使用账号登录后,在首页导航栏中找到“API 文档”入口。
#### 2. **申请 API Key**
登录成功后,可以在个人中心页面生成专属的 `api_key`。此密钥是调用接口的核心凭证[^2]。
#### 3. **探索模型与功能**
在平台广场区域选择所需的模型(如 DeepSeek-R1 或 FunAudioLLM),点击对应模块即可查看详细的 API 参数说明及示例代码[^3]。
#### 4. **具体实现流程**
下面是一个基于 Python 的简单请求案例展示如何利用这些资料完成实际操作:
```python
from pathlib import Path
from openai import OpenAI
def get_unique_filename(base_path):
"""确保文件名唯一"""
counter = 1
while base_path.exists():
name = base_path.stem
ext = base_path.suffix
new_name = f"{name}({counter}){ext}"
base_path = base_path.with_name(new_name)
counter += 1
return base_path
speech_file_path = get_unique_filename(Path(__file__).parent / "output.mp3")
client = OpenAI(
api_key="sk-your_api_key_here", # 替换为自己的 key
base_url="https://api.siliconflow.cn/v1"
)
with client.audio.speech.with_streaming_response.create(
model="FunAudioLLM/CosyVoice2-0.5B",
voice="FunAudioLLM/CosyVoice2-0.5B:david",
input="这是测试文本。",
response_format="mp3"
) as response:
response.stream_to_file(speech_file_path)
```
以上脚本展示了通过流式响应创建音频文件的过程,并指定了特定的声音模型和输出格式[^1]。
---
### 注意事项
- 所有对外服务均遵循 RESTful 架构设计原则。
- 请求头通常需携带认证信息 (`Authorization`) 和媒体类型声明 (`Content-Type: application/json`)。
- 不同端点可能具有独立限频策略,请查阅最新版本指南了解详情。
阅读全文
相关推荐


















