from openai import OpenAI
client = OpenAI(
base_url="https://kymaapi.com/v1",
api_key="ky-your-api-key"
)
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[{"role": "user", "content": "What's the weather in Tokyo?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
}],
tool_choice="auto"
)
message = response.choices[0].message
if message.tool_calls:
for call in message.tool_calls:
print(f"Call: {call.function.name}({call.function.arguments})")