使用地址:openai-api
调用3.5代码
# coding=gbk
import openai
openai.api_base = 'https://api.chuanchuan.cloud/v1'
openai.api_key = 'sk-8fNMAI5HqltUroio74A1D72dB2524487B2D59f675940Bd39'
messages = [
{"role": "user", "content": "你好,你是什么模型?"}
]
res = openai.ChatCompletion.create(
model="gpt-3.5-turbo-16k",
messages=messages,
stream=False,
)
print(res['choices'][0]['message']['content'])
回答如下:
调用4代码
只需要修改model即可:
# coding=gbk
import openai
openai.api_base = 'https://api.chuanchuan.cloud/v1'
openai.api_key = 'sk-8fNMAI5HqltUroio74A1D72dB2524487B2D59f675940Bd39'
messages = [
{"role": "user", "content": "你好,你是什么模型?"}
]
res = openai.ChatCompletion.create(
model="gpt-4",
messages=messages,
stream=False,
)
print(res['choices'][0]['message']['content'])
如下所示:
gpt-4-all(文件分析,绘图,联网)
# coding=gbk
import openai
openai.api_base = 'https://api.chuanchuan.cloud/v1'
openai.api_key = 'sk-8fNMAI5HqltUroio74A1D72dB2524487B2D59f675940Bd39'
messages = [
{"role": "user", "content": "画一只猫"}
]
res = openai.ChatCompletion.create(
model="gpt-4-all",
messages=messages,
stream=False,
)
print(res['choices'][0]['message']['content'])
如下所示: