You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
alpha_tools/test/call_llm_with_anthropic.py

20 lines
643 B

import anthropic
client = anthropic.Anthropic(
api_key="sk-cp-l_as8mjqPhsOIny9IFKZ8jzA92z1c0eRwchldhEf4KzQjs9cjVknV2o7VNCcvYUXsXFq7uF4aSgp2RxxmUHLXwPGKgIvzedM70_XUIXiBB3gu_UmLDQLfh4",
base_url="https://api.minimaxi.com/anthropic"
)
message = client.messages.create(
model="MiniMax-M2.7",
max_tokens=1000,
system="You are a helpful assistant.",
messages=[{"role": "user", "content": [{"type": "text", "text": "Hi, how are you?"}]}]
)
for block in message.content:
if block.type == "thinking":
print(f"Thinking:\n{block.thinking}\n")
elif block.type == "text":
print(f"Text:\n{block.text}\n")