Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : API Atlas8# File : examples/openai/tools/tool-search/tool_search.sh9# Module : examples10# Repository : https://git.spboucher.ai/doc-api11# Created : 2026-09-1812# Last Modified : 2026-09-1813#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: contact@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : None specified (no license file in this repository)32#33# Do not embed credentials, private keys, access tokens,34# certificates or confidential personal information.35#36# =============================================================================37# END OF SP BOUCHER SOURCE HEADER38# =============================================================================3940# Hosted tool search with a deferred function inside a namespace. STATUS: LIVE_VERIFIED 2026-09-18 (gpt-5.4-mini; gpt-5.4-nano lacks tool_search).41# Run: bash examples/openai/tools/tool-search/tool_search.sh42set -eo pipefail # no -u: oai() runs in $(...) subshells, so OAI_STATUS may be unset in the parent43source "$(dirname "$0")/../../../../scripts/lib.sh"44R=$(oai POST /v1/responses -d '{"model":"gpt-5.4-mini","input":"Weather in Paris? Find and use a tool.","max_output_tokens":96,"reasoning":{"effort":"low"},45 "tools":[{"type":"tool_search"},{"type":"namespace","name":"weather","description":"Weather lookup tools","tools":[46 {"type":"function","name":"get_weather","description":"Current weather for a city.","defer_loading":true,"strict":true,47 "parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"],"additionalProperties":false}}]}]}')48log_request openai POST /v1/responses "${OAI_STATUS:-200}" 0.0007 "tool_search.sh"49echo "$R" | jq -c '.output[] | select(.type=="tool_search_call") | {execution, arguments, status}'50echo "$R" | jq -c '.output[] | select(.type=="tool_search_output") | {execution, tools: [.tools[] | (.name // .type)]}'51echo "$R" | jq -c '.output[] | select(.type=="function_call") | {namespace, name, arguments}'52