Documentation Index
Fetch the complete documentation index at: https://docs.linkup.so/llms.txt
Use this file to discover all available pages before exploring further.
Looking for OpenAI SDK?
We have a dedicated guide for using the OpenAI SDK with Linkup.
This tutorial shows you how to use OpenAI’s function calling with Linkup to build a chatbot with real-time web search capabilities.
Get your API Keys
Get your Linkup API key
Create a Linkup account for free to get your API key.
Get your OpenAI API key
Create an OpenAI account for free to get your API key.
Install and Setup
Install the required packages:pip install linkup-sdk openai
Set up your clients:from openai import OpenAI
from linkup import LinkupClient
import json
from datetime import datetime
openai_client = OpenAI(api_key="your_openai_api_key")
linkup_client = LinkupClient(api_key="your_linkup_api_key")
Define the Function Schema
Tell OpenAI about your search function using the Responses API format:tools = [{
"type": "function",
"name": "search_web",
"description": "Search the web for current information. Returns comprehensive content from relevant sources.",
"parameters": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "The search query"
}
},
"required": ["query"]
}
}]
Build the Chatbot
Put it all together in a conversational loop using the Responses API:system_prompt = f"You are a helpful assistant. Today is {datetime.now().strftime('%B %d, %Y')}. Use web search when you need current information."
input_list = [{"role": "system", "content": system_prompt}]
print("Chatbot ready! Type 'quit' to exit.\n")
while True:
user_input = input("You: ").strip()
if not user_input or user_input.lower() == "quit":
break
input_list.append({"role": "user", "content": user_input})
try:
response = openai_client.responses.create(
model="gpt-5",
tools=tools,
input=input_list,
)
while any(item.type == "function_call" for item in response.output):
input_list += response.output
for item in response.output:
if item.type == "function_call":
args = json.loads(item.arguments)
print(f"Searching with Linkup: {args['query']}...")
linkup_response = linkup_client.search(
query=args["query"],
depth="fast",
output_type="searchResults"
)
search_results_json = json.dumps(
linkup_response.model_dump(), indent=2
)
input_list.append({
"type": "function_call_output",
"call_id": item.call_id,
"output": search_results_json
})
response = openai_client.responses.create(
model="gpt-5",
tools=tools,
input=input_list,
)
input_list += response.output
print(f"\nAssistant: {response.output_text}\n")
except Exception as e:
print(f"Error: {e}\n")
input_list.pop()