Linkup Python SDK

0.13.0 · active · verified Thu Apr 16

The Linkup Python SDK provides a client for interacting with the Linkup API, enabling capabilities like web search and content fetching for AI workflows. It supports both synchronous and asynchronous calls, manages authentication, and offers integration with the x402 payment protocol. The library is actively maintained with frequent releases, currently at version 0.13.0.

Common errors

Warnings

Install

Imports

Quickstart

Initializes the LinkupClient and performs a basic search query, retrieving a sourced answer. It demonstrates how to handle the API key, preferably from an environment variable.

import os
from linkup import LinkupClient

# Ensure LINKUP_API_KEY environment variable is set or pass directly
api_key = os.environ.get('LINKUP_API_KEY', '')
if not api_key:
    print("Warning: LINKUP_API_KEY environment variable not set. Please set it or pass 'api_key' to LinkupClient.")
    # For demonstration, you might want to exit or use a placeholder, 
    # but for actual use, a valid key is required.
    # For example: api_key = 'YOUR_ACTUAL_API_KEY'

try:
    client = LinkupClient(api_key=api_key)
    response = client.search(
        query="What are the benefits of using an LLM in a RAG system?",
        depth="standard",
        output_type="sourcedAnswer"
    )
    print(response.answer)
    for source in response.sources:
        print(f"- {source.name}: {source.url}")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →