Skip to content

Commit

Permalink
add model api call guide
Browse files Browse the repository at this point in the history
Signed-off-by: samzong <samzong.lu@gmail.com>
  • Loading branch information
samzong committed Feb 5, 2025
1 parent 945c745 commit 9600854
Show file tree
Hide file tree
Showing 2 changed files with 211 additions and 100 deletions.
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)
201 changes: 101 additions & 100 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 @@ -94,102 +95,102 @@ nav:

# i18n
plugins:
i18n:
docs_structure: folder
reconfigure_material: true
reconfigure_search: true
languages:
- locale: zh
name: 中文
default: true
build: true
- locale: en
name: English
build: true
nav_translations:
首页: Home
d.run 文档: d.run Documentation
注册账号: Register Account
算力云: Compute Cloud
算力市场: Compute Market
容器实例: Container Instances
创建容器实例: Create Instance
容器实例开关机: Power on/off
文件存储: File Storage
大模型服务平台: LLM Studio
模型广场: Model Store
模型部署: Deploy Model
模型服务: Model Service
模型体验: Try a Model
API Key 管理: API Keys
AI 应用: AI Apps
功能列表: Features
应用中心: App Center
创建应用: Create App
应用对话: App Dialogue
语料库: Corpus
创建语料库: Create Corpus
语料管理: Manage Corpus
语料导入: Import Corpus
文件导入: Import File
手动录入: Manual Import
图文导入: Import Image
格式化导入: Formatter Import
数据分析: Data Analysis
问答质量: QA Quality
问答次数: Number of QAs
分片质量: Shard Quality
分片命中率: Shard Hit Ratio
改进意见: Suggestions
我的反馈: My Feedback
费用中心: Billing Center
钱包: Wallet
收支明细: Transactions
订单管理: Orders
账单管理: Bills
个人中心: Personal Center
安全设置: Security Settings
访问密钥: Access Keys
语言设置: Language Settings
帮助与支持: Help and Support
索引: Index
平台服务协议: Service Level Agreement
实名认证服务说明: Real-name Authentication
反挖矿协议: Anti-mining Agreement
AI 行业新闻: Blogs
d.run 是支撑生成式 AI 的理想平台: d.run is the Ideal Platform for Generative AI
K8s 与生成式 AI 珠联璧合: K8s and Generative AI Make a Perfect Match
OpenAI GPT-4o 完全免费: OpenAI GPT-4o is Completely Free
OpenAI 大型语言模型规范: OpenAI LLM Specifications
2024大规模AI基础设施形势调研: 2024 Large-scale AI Infrastructure Survey
云原生人工智能白皮书: Cloud-native Artificial Intelligence White Paper
Kimi火了后国内其他大模型: Kimi Success and Other Domestic LLM
DBRX 开源 LLM 介绍: Introduction to DBRX Open Source LLM
AI 流程编排化算力为算利: Transforms Compute into Profit
谁将替代 Transformer: Who Will Replace the Transformer
金融行业迎来大模型时代: Financial Industry Welcomes the LLM Era
智海拾贝: Knowledge from AI Industry
大模型: LLM
OpenAI: OpenAI
Hugging Face: Hugging Face
月之暗面: Moonshot
Claude 3: Claude 3
硬件厂商: Hardware Manufacturers
华为: Huawei
天数智芯: Iluvatar
国内 AI 先锋企业: Domestic AI Pioneers
阿里巴巴: Alibaba
百川智能: Baichuan Intelligence
百度: Baidu
汉王科技: Hanvon Technology
科大讯飞: iFlytek
旷视科技: Megvii Technology
商汤科技: SenseTime
思必驰: iFlytek
腾讯: Tencent
图森未来: TuSimple
云从科技: CloudWalk Technology
云知声: UniSound
字节跳动: ByteDance
联系我们: Contact Us
2025 年人工智能趋势展望: AI Trend in 2025
i18n:
docs_structure: folder
reconfigure_material: true
reconfigure_search: true
languages:
- locale: zh
name: 中文
default: true
build: true
- locale: en
name: English
build: true
nav_translations:
首页: Home
d.run 文档: d.run Documentation
注册账号: Register Account
算力云: Compute Cloud
算力市场: Compute Market
容器实例: Container Instances
创建容器实例: Create Instance
容器实例开关机: Power on/off
文件存储: File Storage
大模型服务平台: LLM Studio
模型广场: Model Store
模型部署: Deploy Model
模型服务: Model Service
模型体验: Try a Model
API Key 管理: API Keys
AI 应用: AI Apps
功能列表: Features
应用中心: App Center
创建应用: Create App
应用对话: App Dialogue
语料库: Corpus
创建语料库: Create Corpus
语料管理: Manage Corpus
语料导入: Import Corpus
文件导入: Import File
手动录入: Manual Import
图文导入: Import Image
格式化导入: Formatter Import
数据分析: Data Analysis
问答质量: QA Quality
问答次数: Number of QAs
分片质量: Shard Quality
分片命中率: Shard Hit Ratio
改进意见: Suggestions
我的反馈: My Feedback
费用中心: Billing Center
钱包: Wallet
收支明细: Transactions
订单管理: Orders
账单管理: Bills
个人中心: Personal Center
安全设置: Security Settings
访问密钥: Access Keys
语言设置: Language Settings
帮助与支持: Help and Support
索引: Index
平台服务协议: Service Level Agreement
实名认证服务说明: Real-name Authentication
反挖矿协议: Anti-mining Agreement
AI 行业新闻: Blogs
d.run 是支撑生成式 AI 的理想平台: d.run is the Ideal Platform for Generative AI
K8s 与生成式 AI 珠联璧合: K8s and Generative AI Make a Perfect Match
OpenAI GPT-4o 完全免费: OpenAI GPT-4o is Completely Free
OpenAI 大型语言模型规范: OpenAI LLM Specifications
2024大规模AI基础设施形势调研: 2024 Large-scale AI Infrastructure Survey
云原生人工智能白皮书: Cloud-native Artificial Intelligence White Paper
Kimi火了后国内其他大模型: Kimi Success and Other Domestic LLM
DBRX 开源 LLM 介绍: Introduction to DBRX Open Source LLM
AI 流程编排化算力为算利: Transforms Compute into Profit
谁将替代 Transformer: Who Will Replace the Transformer
金融行业迎来大模型时代: Financial Industry Welcomes the LLM Era
智海拾贝: Knowledge from AI Industry
大模型: LLM
OpenAI: OpenAI
Hugging Face: Hugging Face
月之暗面: Moonshot
Claude 3: Claude 3
硬件厂商: Hardware Manufacturers
华为: Huawei
天数智芯: Iluvatar
国内 AI 先锋企业: Domestic AI Pioneers
阿里巴巴: Alibaba
百川智能: Baichuan Intelligence
百度: Baidu
汉王科技: Hanvon Technology
科大讯飞: iFlytek
旷视科技: Megvii Technology
商汤科技: SenseTime
思必驰: iFlytek
腾讯: Tencent
图森未来: TuSimple
云从科技: CloudWalk Technology
云知声: UniSound
字节跳动: ByteDance
联系我们: Contact Us
2025 年人工智能趋势展望: AI Trend in 2025

0 comments on commit 9600854

Please sign in to comment.