Skip to main content
Tool definitions use a flat schema ({type, name, parameters}) and tool results are function_call_output input items with a call_id and output string.

Prerequisites

  • An Auriko API key
  • Python 3.10+ with the OpenAI SDK (pip install openai) or the Auriko SDK (pip install auriko)
    • OR Node.js 18+ with the OpenAI SDK (npm install openai) or @auriko/sdk (npm install @auriko/sdk)

Define tools

Define a tool with the flat schema format:
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"]
        }
    }
]
Chat Completions wraps these fields under a nested function key.

Call tools

Send a request with tools and inspect the function_call output item:
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

response = client.responses.create(
    model="gpt-4o",
    input="What's the weather in Tokyo?",
    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"]
        }
    }]
)

for item in response.output:
    if item.type == "function_call":
        print(f"Function: {item.name}")
        print(f"Arguments: {item.arguments}")
        print(f"Call ID: {item.call_id}")

Submit tool results

Match the call_id from the function call output to link your result back to the original request:
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)
Submitting tool results requires state from a previous response. For single-request examples, see Call tools.

Use parallel tool calls

Set parallel_tool_calls: true to let the model call multiple functions in one response:
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

response = client.responses.create(
    model="gpt-4o",
    input="What's the weather in Tokyo and London?",
    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"]
        }
    }],
    parallel_tool_calls=True
)

for item in response.output:
    if item.type == "function_call":
        print(f"{item.name}({item.arguments})")

Control tool choice

Set tool_choice to control when the model calls tools:
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

response = client.responses.create(
    model="gpt-4o",
    input="What's the weather in Tokyo?",
    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"]
        }
    }],
    tool_choice="required"
)

print(response.output[0].type)
"auto" (default) lets the model decide. "required" forces a tool call. "none" prevents tool calls. {"type": "function", "name": "get_weather"} forces a specific function. See Tool Calling guide for provider-specific behavior.

Stream tool calls

Stream function call arguments as they’re generated:
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AURIKO_API_KEY"],
    base_url="https://api.auriko.ai/v1"
)

stream = client.responses.create(
    model="gpt-4o",
    input="What's the weather in Tokyo?",
    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"]
        }
    }],
    stream=True
)

for event in stream:
    if event.type == "response.function_call_arguments.delta":
        print(event.delta, end="", flush=True)
    elif event.type == "response.function_call_arguments.done":
        print(f"\nComplete: {event.arguments}")
The .done event includes the complete arguments string, so you don’t need to reassemble delta chunks.