Skip to main content

API Compatible with Open AI

under construction

The English version of this document is under construction and will be available soon.


支援模型清單
  • 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_URLAPI_KEY,取得方式請見此文件


方法一:curl

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

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)