SDK
安装 Portkey SDK
npm install --save portkey-aipip install portkey-ai导出 Portkey API 密钥
export PORTKEY_API_KEY=""基本客户端设置
import Portkey from 'portkey-ai';
// Construct a client with a virtual key
const portkey = new Portkey({
apiKey: "PORTKEY_API_KEY",
virtualKey: "VIRTUAL_KEY"
})
// Construct a client with a config id
const portkey = new Portkey({
apiKey: "PORTKEY_API_KEY",
config: "cf-***" // Supports a string config slug or a config object
})from portkey_ai import Portkey
# 使用虚拟密钥构建客户端
portkey = Portkey(
api_key="PORTKEY_API_KEY",
virtual_key="VIRTUAL_KEY"
)
# 使用提供者和提供者 API 密钥构建客户端
portkey = Portkey(
api_key="PORTKEY_API_KEY",
config="cf-***" # 支持字符串配置标识符或配置对象
)发起请求
传递 Trace ID 或元数据
Async 使用
参数
参数
类型
键
stringrequired
string
stringobject
string
string
string
object
boolean
string
string
array of string
string
string
string
参数
类型
键
stringrequired
string
stringobject
string
string
string
object
boolean
string
string
array of string
string
string
string
参数
类型
头部键
stringrequired
string
string
string
string
string
string
boolean
string
string
array of string
string
string
string
Last updated