GPT_API调用

免费版

免费的api-key https://github.com/chatanywhere/GPT_API_free

alt text

详情建议多看看文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 测试代码
from openai import OpenAI

client = OpenAI(
# defaults to os.environ.get("OPENAI_API_KEY")
api_key="your keys",
base_url="https://api.chatanywhere.tech/v1"
# base_url="https://api.chatanywhere.cn/v1"
)

completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."},
{"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
]
)

print(completion.choices[0].message)

收费版(不推荐)

wildcard

邀请码:DUMMYV077 直接点链接也可以
https://wildcard.com.cn/i/DUMMYV077
alt text
它有个这个api,如果你只需要api不需要gpt plus那个,就可以试试这个,我因为当时有plus的需求就,选择的是开卡充钱那种方式。
alt text

API-key

这里默认你已经拥有魔法和openai账号。
转到openai platfrom的网站
https://platform.openai.com/playground/

点那个increase limit进去,
alt text
这里可以修改限额参数
alt text
再往下滑可以,进行充值
alt text