import os
import json
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AURIKO_API_KEY"],
base_url="https://api.auriko.ai/v1"
)
tools = [{
"type": "function",
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}]
response = client.responses.create(
model="gpt-4o",
input="What's the weather in Tokyo?",
tools=tools
)
tool_call = next(item for item in response.output if item.type == "function_call")
final = client.responses.create(
model="gpt-4o",
input=[
{"type": "message", "role": "user", "content": "What's the weather in Tokyo?"},
{"type": "function_call", "name": tool_call.name, "call_id": tool_call.call_id, "arguments": tool_call.arguments},
{"type": "function_call_output", "call_id": tool_call.call_id, "output": json.dumps({"temperature": "22°C", "condition": "Sunny"})}
],
tools=tools
)
print(final.output_text)