Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add model api call guide #223

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions docs/zh/docs/models/api-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
status: new
---

# 模型调用

D.run 提供了两种的大模型的托管方式,您可以根据您的需求选择合适的方式,本文介绍不同方式的 API 调用说明。

- MaaS by Token: 使用 token 计费,共享资源,用户无需部署模型实例,即可调用模型。
- 模型服务: 用户独享实例,按实例计费,API 调用不限制次数。

## 支持的模型与托管方式

| 模型名称 | MaaS by Token | 模型服务 |
| ----------------------------- | ------------- | -------- |
| 🔥 DeepSeek-R1 | ✅ | |
| 🔥 DeepSeek-V3 | ✅ | |
| 🔥 MiniMax-Text-01 | ✅ | |
| Phi-4 | | ✅ |
| Phi-3.5-mini-instruct | | ✅ |
| Qwen2-0.5B-Instruct | | ✅ |
| Qwen2.5-7B-Instruct | ✅ | ✅ |
| Qwen2.5-14B-Instruct | | ✅ |
| Qwen2.5-Coder-32B-Instruct | | ✅ |
| Qwen2.5-72B-Instruct-AWQ | ✅ | ✅ |
| baichuan2-13b-Chat | | ✅ |
| Llama-3.2-11B-Vision-Instruct | ✅ | ✅ |
| glm-4-9b-chat | ✅ | ✅ |

## 模型 Endpoint

| 调用方式 | Endpoint |
| ------------- | ------------------- |
| MaaS by Token | `chat.d.run` |
| 模型服务 | `<region>-02.d.run` |

## API 调用示例

### 使用 MaaS by Token 调用

要使用 MaaS by Token 调用模型,请按照以下步骤操作:

1. **获取 API Key**: 登录用户控制台,创建一个新的 API Key。
2. **设置 Endpoint**: 将 SDK 的 endpoint 替换为 `chat.d.run`。
3. **调用模型**: 使用官方的模型名称和新的 API Key 进行调用。

**示例代码 (Python)**:

```python
import openai

openai.api_key = "your-api-key" # 替换为您的 API Key
openai.api_base = "https://chat.d.run"

response = openai.Completion.create(
model="public/deepseek-r1",
prompt="What is your name?"
)

print(response.choices[0].text)
```

### 使用独立模型服务调用

要使用用户自己部署的模型实例进行调用,请按照以下步骤操作:

1. **部署模型实例**: 在指定的区域部署模型实例,例如 `sh-02`。
2. **获取 API Key**: 登录用户控制台,创建一个新的 API Key。
3. **设置 Endpoint**: 将 SDK 的 endpoint 替换为 `<region>.d.run`,例如 `sh-02.d.run`。
4. **调用模型**: 使用官方的模型名称和新的 API Key 进行调用。

**示例代码 (Python)**:

```python
import openai

openai.api_key = "your-api-key" # 替换为您的 API Key
openai.api_base = "https://sh-02.d.run" # 替换为您的模型服务所在的区域

response = openai.Completion.create(
model="u-1100a15812cc/qwen2", # 替换为您的模型服务访问名称
prompt="What is your name?"
)

print(response.choices[0].text)
```

## 常见问题

### Q: 如何选择调用方式?

- **MaaS by Token**: 适用于轻量级、不频繁的调用场景。
- **Instance**: 适用于需要高性能、频繁调用的场景。

### Q: 如何查看我的 API Key?

登录用户控制台,进入 API Key 管理页面即可查看和管理您的 API Key,参考[API Key 管理](apikey.md)。

### Q: 如何获取模型名称?

- MaaS by Token 的模型名称由 `public/` 和模型名称组成,例如 `public/deepseek-r1`,可在模型详情页查看。
- 模型服务部署的模型名称由用户名和模型名称组成,例如 `u-1100a15812cc/qwen2`,可在模型列表一键复制。

### Q: 部署模型实例的费用如何计算?

费用根据部署的区域、实例规格和使用时长计算。具体费用请参考用户控制台的实例定价页面。

## 支持与反馈

如有任何问题或反馈,请联系我们的[技术支持团队](../contact/index.md)。
5 changes: 3 additions & 2 deletions docs/zh/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ nav:
- 注册账号: index.md
- 算力云:
- 算力市场: zestu/index.md
- 容器实例:
- 容器实例:
- 创建容器实例: zestu/instance.md
- 容器实例开关机: zestu/instance-on-off.md
- 文件存储: zestu/storage.md
Expand All @@ -14,6 +14,7 @@ nav:
- 模型部署: models/deploy.md
- 模型服务: models/service.md
- 模型体验: models/exp.md
- 模型调用: models/api-call.md
- API Key 管理: models/apikey.md
- AI 应用:
- 功能列表: dak/features.md
Expand Down Expand Up @@ -192,4 +193,4 @@ plugins:
云知声: UniSound
字节跳动: ByteDance
联系我们: Contact Us
2025 年人工智能趋势展望: AI Trend in 2025
2025 年人工智能趋势展望: AI Trend in 2025
Loading