身份验证
获取您的 API 密钥
使用SDK进行身份验证
Portkey SDKs
import Portkey from 'portkey-ai'
const portkey = new Portkey({
apiKey: "PORTKEY_API_KEY", // 替换为您的实际 API 密钥
virtualKey: "VIRTUAL_KEY" // 可选:用于虚拟密钥管理
})
const chatCompletion = await portkey.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-3.5-turbo',
});
console.log(chatCompletion.choices);from portkey_ai import Portkey
client = Portkey(
api_key="PORTKEY_API_KEY", # 替换为您的实际 API 密钥
virtual_key="VIRTUAL_KEY" # 可选:如果设置了虚拟密钥,请使用
)
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": "Say this is a test"}],
model='gpt-3.5-turbo'
)
print(chat_completion.choices[0].message["content"])OpenAI SDK
Last updated