获取免费chatgpt apikey
第一步 访问github marketplace打开github:(没有账号需要先注册账号)https://github.com/marketplace/models/azure-openai/gpt-4-1/playground

第二步 申请apikey点击Get developer key

选择classic,输入Note

拖到底部,点击Generate token

然后把token复制下来。
第三步 配置到dify中 (重点)
输入模型名称:openai/gpt-4.1
API Key:您刚申请的APIkeyAPI
endpoint URL:https://models.github.ai/inference
模型上下文长度:1049000
python文件引用
# ========== 1. 配置 ==========
client = OpenAI(api_key="你的apikey", base_url="https://models.github.ai/inference")
resp = client.chat.completions.create(
model="gpt-4o-mini",
# model="gpt-3.5-turbo",
messages=[{"role": "user", "content": prompt}],
temperature=0.4,
)
# print(resp)
return resp.choices[0].message.content

浙公网安备 33010602011771号