Linkup

Linkup is a web search API that returns sourced answers grounded in real-time web data. Use it through the Respan gateway to ground LLM completions with fresh information, rendered into your prompts via template variables.

Create an account at platform.respan.ai and grab an API key. For gateway, also add credits or a provider key.

Run npx @respan/cli setup to set up with your coding agent.

Linkup is a gateway-only integration. Calls run through the Respan gateway and are automatically traced.

Setup

1

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
$export LINKUP_API_KEY="YOUR_LINKUP_API_KEY"
2

Add Linkup parameters to your request

Include linkup_params in your request body. The Linkup response is rendered into your prompt as {{ linkup_search_response }}.

1import os
2import requests
3
4response = requests.post(
5 "https://api.respan.ai/api/chat/completions",
6 headers={
7 "Content-Type": "application/json",
8 "Authorization": f"Bearer {os.environ['RESPAN_API_KEY']}",
9 },
10 json={
11 "model": "gpt-4.1-nano",
12 "messages": [
13 {"role": "system", "content": "You are a helpful assistant."},
14 {"role": "user", "content": "Please summarize: {% if linkup_search_response %}{{ linkup_search_response.answer }}{% endif %}"},
15 ],
16 "linkup_params": {
17 "api_key": os.environ["LINKUP_API_KEY"],
18 "q": "What is Microsoft's 2024 revenue?",
19 "depth": "deep",
20 "outputType": "sourcedAnswer",
21 "includeImages": False,
22 },
23 },
24)
25print(response.json())

Template variables

Use Jinja2 syntax to render Linkup responses in your messages. See the Jinja2 docs.

{% if linkup_search_response %}
{{ linkup_search_response.answer }}
Sources:
{% for source in linkup_search_response.sources %}
- {{ source.name }}: {{ source.url }}
{{ source.snippet }}
{% endfor %}
{% endif %}

Parameters

ParameterTypeDescriptionDefault
qstringThe search query.Required
depthstringSearch depth: "standard" or "deep"."deep"
outputTypestring"searchResults", "sourcedAnswer", or "structured"."sourcedAnswer"
structuredOutputSchemastringSchema for structured output.null
includeImagesbooleanWhether to include images in the response.false

Response structure

1{
2 "answer": "The answer text",
3 "sources": [
4 {
5 "name": "Source name",
6 "url": "Source URL",
7 "snippet": "Text snippet from the source"
8 }
9 ]
10}

Error handling

If the Linkup API call fails, the error is added to warnings_dict in the response under the key LINKUP_SEARCH_ERROR.