Linkup Python SDK
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
-
ImportError: cannot import name 'LinkupClient' from 'linkup_sdk'
cause Attempting to import `LinkupClient` from `linkup_sdk` instead of `linkup`.fixChange the import statement to `from linkup import LinkupClient`. -
linkup.exceptions.AuthenticationError: Missing API key. Please provide it as an environment variable (LINKUP_API_KEY) or pass it directly to the LinkupClient constructor.
cause The Linkup API key was not found in environment variables nor passed during client initialization.fixSet the `LINKUP_API_KEY` environment variable, or pass `api_key='your_key_here'` when creating `LinkupClient`. -
linkup.exceptions.LinkupAPIError: Rate limit exceeded. Please wait before making further requests or contact support for higher limits.
cause Too many API requests were made within a short period, exceeding the allocated rate limit.fixImplement exponential backoff and retry logic in your application. Review Linkup's rate limit documentation for details, or contact Linkup support to request a higher rate limit. -
TypeError: LinkupClient.search() got an unexpected keyword argument 'source_filter'
cause Attempting to use a parameter name that either does not exist or has been renamed in a newer version of the SDK.fixConsult the official Linkup SDK documentation or the GitHub repository's `CHANGELOG.md` for the correct parameter names and usage for your installed version. Parameter names and available options (e.g., `depth`, `output_type`) can evolve.
Warnings
- breaking Internal error handling logic was moved in v0.12.0. If you were relying on catching specific internal exceptions or inspecting their structure, your code might break.
- breaking Internal modules were made private in v0.8.0. Direct imports from `linkup._internal.*` or similar paths are no longer supported and will raise an `ImportError` or `AttributeError`.
- gotcha For optimal performance in production environments, especially when making multiple API calls, consider using the asynchronous client methods (e.g., `async_search` instead of `search`).
- gotcha The Linkup API Key is crucial for authentication. It must be provided either via the `LINKUP_API_KEY` environment variable or passed directly as the `api_key` argument to the `LinkupClient` constructor.
Install
-
pip install linkup-sdk -
pip install linkup-sdk[x402]
Imports
- LinkupClient
from linkup_sdk import LinkupClient
from linkup import LinkupClient
Quickstart
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}")