Seltz Python SDK for AI-powered search
Project description
Seltz Python SDK
The official Python SDK for the Seltz AI-powered search API.
Installation
pip install seltz
Quick Start
from seltz import Seltz
# Initialize with API key
client = Seltz(api_key="your-api-key")
# Perform a search
response = client.search("your search query")
# Access results
for document in response.documents:
print(f"URL: {document.url}")
print(f"Content: {document.content}")
API Key
Set your API key using one of these methods:
-
Environment variable (recommended):
export SELTZ_API_KEY="your-api-key"
-
Direct parameter:
client = Seltz(api_key="your-api-key")
API Reference
Seltz(api_key=None, endpoint="grpc.seltz.ai", insecure=False)
Creates a new Seltz client instance.
Parameters:
api_key(str, optional): API key for authentication. Defaults toSELTZ_API_KEYenvironment variable.endpoint(str): API endpoint. Defaults to "grpc.seltz.ai".insecure(bool): Use insecure connection. Defaults to False.
Returns: Seltz instance
client.search(query, *, includes=None, context=None, profile=None)
Performs a search query.
Parameters:
query(str): The search query text. Keep concise for best performance.includes(Includes, optional): ProtobufIncludesmessage configuring result options.context(str, optional): Additional context for the query. Include as much relevant information as feasible to improve search quality.profile(str, optional): Search profile to use (contact support for available profiles).
Returns: SearchResponse — protobuf message. Access results via response.documents.
Examples:
response = client.search("Python asyncio tutorial")
# With Includes configuration
from seltz import Includes
response = client.search(
"Python tutorial",
includes=Includes(max_documents=10)
)
# Iterate results
for doc in response.documents:
print(f"URL: {doc.url}")
print(f"Content: {doc.content}")
# Common patterns
first = response.documents[0] if response.documents else None
urls = [doc.url for doc in response.documents if doc.url]
count = len(response.documents)
Includes
Protobuf message configuring what to include in search results. Accepts any fields defined in the proto schema — new fields are automatically available as the API evolves.
from seltz import Includes
includes = Includes(max_documents=5)
response = client.search("query", includes=includes)
SearchResponse and Document
search() returns a SearchResponse protobuf message directly.
SearchResponse fields:
documents: RepeatedDocumentmessages (iterable, supports indexing andlen())
Document fields:
url(str): Document URL. Returns""when not set — useif doc.url:to check presence.content(str): Document content. Returns""when not set — useif doc.content:to check presence.
result = client.search("Python tutorial")
print(f"Found {len(result.documents)} documents")
for doc in result.documents:
if doc.url:
print(f"URL: {doc.url}")
if doc.content:
print(f"Content: {doc.content[:100]}")
# Index access
first = result.documents[0] if result.documents else None
# Serialize to dict
from google.protobuf.json_format import MessageToDict
as_dict = MessageToDict(result)
Note on optional fields:
Document.urlandDocument.contentare proto3 optional string fields. They return""(empty string) when unset, notNone. Both are falsy, soif doc.url:works correctly. Avoiddoc.url is not Nonechecks.
Error Handling
from seltz import (
Seltz,
SeltzConfigurationError,
SeltzAuthenticationError,
SeltzConnectionError,
SeltzAPIError,
SeltzTimeoutError,
SeltzRateLimitError,
)
try:
client = Seltz(api_key="your-api-key")
response = client.search("query")
except SeltzConfigurationError as e:
print(f"Configuration error: {e}")
except SeltzAuthenticationError as e:
print(f"Authentication error: {e}")
except SeltzConnectionError as e:
print(f"Connection error: {e}")
except SeltzTimeoutError as e:
print(f"Timeout error: {e}")
except SeltzRateLimitError as e:
print(f"Rate limit error: {e}")
except SeltzAPIError as e:
print(f"API error: {e}")
Requirements
- Python 3.8+
- grpcio >= 1.76.0
- protobuf < 6.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file seltz-0.2.0.tar.gz.
File metadata
- Download URL: seltz-0.2.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6549ab29507195231af180d0d665f6b90490f1d6cbd8bc2cdba1561139f3a82d
|
|
| MD5 |
49d40f69ced2c0cdb957862f53ba34e1
|
|
| BLAKE2b-256 |
9e9afb73753caabb67f59daabb4eef1dea39c8309161d2ceba325963967e3118
|
File details
Details for the file seltz-0.2.0-py3-none-any.whl.
File metadata
- Download URL: seltz-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0bc5399f48d3284dadf7860e0682e5f013ce0bc14abbd731d4491fb4b6843e5
|
|
| MD5 |
050ee68bd0e43ecde1fdaaab4d4fdcce
|
|
| BLAKE2b-256 |
fa2726d7d21f44a559b7a99dce66f61db294b868f1e0f646cd954f751bb63af8
|