+
99
-

回答

还有github免费提供gpt4.1的试验场与api,直接申请就行github的tokens后就能使用代码调用api

g800_auto

800_auto

import os
from openai import OpenAI

token = os.environ["GITHUB_TOKEN"]
endpoint = "https://models.github.ai/inference"
model = "openai/gpt-4.1"

client = OpenAI(
    base_url=endpoint,
    api_key=token,
)

response = client.chat.completions.create(
    messages=[
        {
            "role": "system",
            "content": "You are a helpful assistant.",
        },
        {
            "role": "user",
            "content": "What is the capital of France?",
        }
    ],
    temperature=1.0,
    top_p=1.0
    model=model
)

print(response.choices[0].message.content)

https://github.com/marketplace/

网友回复

我知道答案,我要回答