API Compatible with Open AI
支援模型清單
- Llama3.1-FFM (8B、70B)
- Llama3-FFM (8B、70B)
- FFM-Mistral (7B) 、FFM-Mixtral (8x7B)
- FFM-Llama2-v2 (7B 、 13B 、70B)
- FFM-Llama2 (7B 、 13B 、70B)
注意事項
僅支援 Completions 與 Chat completion。
請先至 AFS MS 公用模式、私有模式或 AFS Cloud 取得 API_URL
與 API_KEY
,取得方式請見此文件。
方法一:curl
- 將 ‘
API_URL
/models/completions`\ 填入 API 端點- AFS MS 公用模式為 https://api-ams.twcc.ai/api
- AFS MS 私有模式為 https://xxxxx.afs.twcc.ai/text-generation/api/v4
- 將 'Authorization: Bearer
API_KEY
' \ 填入 API KEY - 將 "model":
MODEL_NAME
", 填入模型名稱,以下以 llama3-ffm-8b-chat 示範,其他模型名稱請見 AFS 可用模型列表
curl --location '{API_URL}/models/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {API_KEY}' \
--data '{
"model": "llama3-ffm-8b-chat",
"prompt": "Say this is a test",
"temperature": 0.5,
"max_tokens": 500
}'
方法二:Python
- 將 API_KEY = "{
API_KEY
}" 填入 API KEY - 將 BASE_URL = "{
API_URL
}/models" 填入 API 端點- AFS MS 公用模式為 https://api-ams.twcc.ai/api
- AFS MS 私有模式為 https://xxxxx.afs.twcc.ai/text-generation/api/v4
- 將 "model": {
MODEL_NAME
}", 填入模型名稱,以下以 llama3-ffm-8b-chat 示範,其他模型名稱請見 AFS 可用模型列表
from openai import OpenAI
import json
API_KEY = "{API_KEY}"
BASE_URL = "{API_URL}/models"
client = OpenAI(
api_key = API_KEY,
base_url = BASE_URL
)
response = client.chat.completions.create(
model = "llama3-ffm-8b-chat",
temperature = 0.5,
max_tokens = 100,
top_p = 0.95,
messages = [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
stream = False
)
print(response)