当前位置:   article > 正文

国内调用GPT_中国内gpt api

中国内gpt api

from openai import OpenAI

client = OpenAI(
base_url=“https://api.gpts.vin/v1”,
api_key=“sk-xxx”
)

completion = client.chat.completions.create(
model=“gpt-3.5-turbo”,
messages=[
{“role”: “system”, “content”: “You are a helpful assistant.”},
{“role”: “user”, “content”: “Hello!”}
]
)

print(completion)

2
curl --request POST
–url https://api.gpts.vin/v1/chat/completions/
–header ‘Authorization: Bearer sk-xxx’
–header ‘content-type: application/json
–data ‘{
“model”: “gpt-4”,
“messages”: [
{
“role”: “user”,
“content”: “say 1”
}
]
}’

3
curl --request POST
–url https://api.gpts.vin/v1/chat/completions
–header ‘Authorization: Bearer sk-xxx’
–header ‘content-type: application/json’
–data ‘{
“messages”: [
{
“role”: “user”,
“content”: [
{
“type”: “text”,
“text”: “题目是什么”
},
{
“type”: “image_url”,
“image_url”: {
“url”: “https://pics4.baidu.com/feed/f31fbe096b63f62430fdd9e135548ef51b4ca34a.jpeg@f_auto?token=bd2415d6c1c854c59b59a590b8bc3447”
}
}
]
}
],
“max_tokens”: 3000,
“temperature”: 1,
“top_p”: 1,
“n”: 1,
“stream”: false,
“presence_penalty”: 0,
“frequency_penalty”: 0,
“model”: “gpt-4-vision-preview”
}’

4
openai.api_key = “sk-OIm6zIBeWFyvPvOyFfB07e9f5bB949F3A331635f52C56064”
openai.api_base = “https://api.gpts.vin/v1”;

5
openai.api_base = ‘https://api.gpts.vin/v1’
openai.api_key = ‘sk-xxxxxxxxxxx’

res = openai.Image.create(
prompt=‘Cat’
)
print(res)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/939676
推荐阅读
相关标签
  

闽ICP备14008679号