{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)
- OR Node.js 18+ with the OpenAI 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"]
}
}
]
const tools = [
{
type: "function" as const,
name: "get_weather",
description: "Get current weather for a location",
parameters: {
type: "object",
properties: {
location: { type: "string", description: "City name" },
},
required: ["location"],
},
},
];
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"]
}
}
]
const tools = [
{
type: "function" as const,
name: "get_weather",
description: "Get current weather for a location",
parameters: {
type: "object",
properties: {
location: { type: "string", description: "City name" },
},
required: ["location"],
},
},
];
function key.
Call tools
Send a request with tools and inspect thefunction_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}")
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AURIKO_API_KEY,
baseURL: "https://api.auriko.ai/v1",
});
const response = await 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 (const item of response.output) {
if (item.type === "function_call") {
console.log(`Function: ${item.name}`);
console.log(`Arguments: ${item.arguments}`);
console.log(`Call ID: ${item.call_id}`);
}
}
import os
from auriko import Client
client = Client(
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}")
import { Client } from "@auriko/sdk";
const client = new Client({
apiKey: process.env.AURIKO_API_KEY,
baseUrl: "https://api.auriko.ai/v1",
});
const response = await 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 (const item of response.output) {
if (item.type === "function_call") {
console.log(`Function: ${item.name}`);
console.log(`Arguments: ${item.arguments}`);
console.log(`Call ID: ${item.call_id}`);
}
}
curl https://api.auriko.ai/v1/responses \
-H "Authorization: Bearer $AURIKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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"]
}
}]
}'
Submit tool results
Match thecall_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)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AURIKO_API_KEY,
baseURL: "https://api.auriko.ai/v1",
});
const tools = [{
type: "function" as const,
name: "get_weather",
description: "Get current weather for a location",
parameters: {
type: "object",
properties: {
location: { type: "string", description: "City name" },
},
required: ["location"],
},
}];
const response = await client.responses.create({
model: "gpt-4o",
input: "What's the weather in Tokyo?",
tools,
});
const toolCall = response.output.find((item) => item.type === "function_call");
const final = await client.responses.create({
model: "gpt-4o",
input: [
{ type: "message", role: "user", content: "What's the weather in Tokyo?" },
{ type: "function_call", name: toolCall.name, call_id: toolCall.call_id, arguments: toolCall.arguments },
{ type: "function_call_output", call_id: toolCall.call_id, output: JSON.stringify({ temperature: "22°C", condition: "Sunny" }) },
],
tools,
});
console.log(final.output_text);
import os
import json
from auriko import Client
client = Client(
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)
import { Client } from "@auriko/sdk";
const client = new Client({
apiKey: process.env.AURIKO_API_KEY,
baseUrl: "https://api.auriko.ai/v1",
});
const tools = [{
type: "function" as const,
name: "get_weather",
description: "Get current weather for a location",
parameters: {
type: "object",
properties: {
location: { type: "string", description: "City name" },
},
required: ["location"],
},
}];
const response = await client.responses.create({
model: "gpt-4o",
input: "What's the weather in Tokyo?",
tools,
});
const toolCall = response.output.find((item) => item.type === "function_call");
const final = await client.responses.create({
model: "gpt-4o",
input: [
{ type: "message", role: "user", content: "What's the weather in Tokyo?" },
{ type: "function_call", name: toolCall.name, call_id: toolCall.call_id, arguments: toolCall.arguments },
{ type: "function_call_output", call_id: toolCall.call_id, output: JSON.stringify({ temperature: "22°C", condition: "Sunny" }) },
],
tools,
});
console.log(final.output_text);
Use parallel tool calls
Setparallel_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})")
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AURIKO_API_KEY,
baseURL: "https://api.auriko.ai/v1",
});
const response = await 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 (const item of response.output) {
if (item.type === "function_call") {
console.log(`${item.name}(${item.arguments})`);
}
}
import os
from auriko import Client
client = Client(
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})")
import { Client } from "@auriko/sdk";
const client = new Client({
apiKey: process.env.AURIKO_API_KEY,
baseUrl: "https://api.auriko.ai/v1",
});
const response = await 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 (const item of response.output) {
if (item.type === "function_call") {
console.log(`${item.name}(${item.arguments})`);
}
}
curl https://api.auriko.ai/v1/responses \
-H "Authorization: Bearer $AURIKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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
}'
Control tool choice
Settool_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)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AURIKO_API_KEY,
baseURL: "https://api.auriko.ai/v1",
});
const response = await 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",
});
console.log(response.output[0].type);
import os
from auriko import Client
client = Client(
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)
import { Client } from "@auriko/sdk";
const client = new Client({
apiKey: process.env.AURIKO_API_KEY,
baseUrl: "https://api.auriko.ai/v1",
});
const response = await 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",
});
console.log(response.output[0].type);
curl https://api.auriko.ai/v1/responses \
-H "Authorization: Bearer $AURIKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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"
}'
"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}")
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AURIKO_API_KEY,
baseURL: "https://api.auriko.ai/v1",
});
const stream = await 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 await (const event of stream) {
if (event.type === "response.function_call_arguments.delta") {
process.stdout.write(event.delta);
} else if (event.type === "response.function_call_arguments.done") {
console.log(`\nComplete: ${event.arguments}`);
}
}
import os
from auriko import Client
client = Client(
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}")
import { Client } from "@auriko/sdk";
const client = new Client({
apiKey: process.env.AURIKO_API_KEY,
baseUrl: "https://api.auriko.ai/v1",
});
const stream = await 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 await (const event of stream) {
if (event.type === "response.function_call_arguments.delta") {
process.stdout.write(event.delta);
} else if (event.type === "response.function_call_arguments.done") {
console.log(`\nComplete: ${event.arguments}`);
}
}
curl --no-buffer https://api.auriko.ai/v1/responses \
-H "Authorization: Bearer $AURIKO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"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
}'
.done event includes the complete arguments string, so you don’t need to reassemble delta chunks.