獲取免費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

浙公網(wǎng)安備 33010602011771號