from openai import OpenAI
client = OpenAI(
api_key = "$MOONSHOT_API_KEY",
base_url = "https://api.moonshot.ai/v1",
)
completion = client.chat.completions.create(
model = "kimi-k2.5",
messages = [
{"role": "system", "content": "You are Kimi, an AI assistant provided by Moonshot AI. You are proficient in Chinese and English conversations. You provide users with safe, helpful, and accurate answers. You will reject any questions involving terrorism, racism, or explicit content. Moonshot AI is a proper noun and should not be translated."},
{"role": "user", "content": "Determine whether 3214567 is a prime number through programming."}
],
tools = [{
"type": "function",
"function": {
"name": "CodeRunner",
"description": "A code executor that supports running Python and JavaScript code",
"parameters": {
"properties": {
"language": {
"type": "string",
"enum": ["python", "javascript"]
},
"code": {
"type": "string",
"description": "The code is written here"
}
},
"type": "object"
}
}
}]
)
print(completion.choices[0].message)