import anthropic
# Initialize the client, if you already set `ANTHROPIC_BASE_URL` and `ANTHROPIC_API_KEY`
# in the environment variables, you can omit the `api_key` and `base_url` parameters.
client = anthropic.Anthropic(
base_url="https://api.novita.ai/anthropic",
api_key="<YOUR_NOVITA_API_KEY>",
# Rewrite header
default_headers={
"Content-Type": "application/json",
"Authorization": "Bearer <YOUR_NOVITA_API_KEY>",
}
)
message = client.messages.create(
model="moonshotai/kimi-k2-instruct",
max_tokens=1000,
temperature=1,
system=[
{
"type": "text",
"text": "You are a world-class poet. Respond only with short poems."
}
],
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "Why is the ocean salty?"
}
]
}
]
)
print(message.content)