Chuyển tới nội dung chính

Tich hop Python

Chat co ban

key = 'sk-xxxx'

from openai import OpenAI

client = OpenAI(
base_url="https://api.aizn.com/v1",
api_key=key
)

response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Hello?"}
]
)
print(response)

Trang vi du

Quy uoc tich hop

  • Use https://api.aizn.com/v1 as the shared base_url
  • Use the console-generated Bearer token as the api_key