import anthropic
# 初始化客户端,如果您已经通过环境变量 `ANTHROPIC_BASE_URL` 和 `ANTHROPIC_API_KEY`
# 设置了 API Key 和 base URL,可以省略 `api_key` 和 `base_url` 参数。
client = anthropic.Anthropic(
base_url="https://api.ppinfra.com/anthropic",
api_key="<PPIO 派欧云 API Key>",
# 重写 header
default_headers={
"Content-Type": "application/json",
"Authorization": "Bearer <PPIO 派欧云 API Key>",
}
)
message = client.messages.create(
model="moonshotai/kimi-k2-instruct",
max_tokens=1000,
temperature=1,
system=[
{
"type": "text",
"text": "你是 PPIO派欧云 AI 助手,你会以诚实专业的态度帮助用户,用中文回答问题。"
}
],
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "你是谁?"
}
]
}
]
)
print(message.content)