relevan
Python client for the Relevan search API.
- Typed, generated from Relevan's live OpenAPI 3.1 spec (
GET /openapi). - Sync and async clients with the same method surface.
- Retries on rate limits, honoring the server's
Retry-Afterheader. - Beta endpoints are grouped under
client.betaand warn on every call.
Install
pip install relevan
Quickstart
from relevan import Client
client = Client() # reads RELEVAN_API_KEY from the environment
org = client.organizations.list()[0]
skill_doc = client.skill.get(org.id, "products") # read once before querying an index
results = client.search.search(org.id, "products", query="wireless headphones")
for hit in results.results:
print(hit.id, hit.explanation)
# Close the loop: tell Relevan what happened to a result.
client.beta.send_feedback(
org.id,
"products",
action_name="click",
query_id=results.search_context.query_id,
object_id=results.results[0].id,
position=0,
)
An agent can also grade the whole search once per query with a
search_judgment, with optional per-result grades from 0 (not useful) to 2
(very useful):
client.beta.send_feedback(
org.id,
"products",
action_name="search_judgment",
query_id=results.search_context.query_id,
grade=1,
results=[{"object_id": results.results[0].id, "grade": 2, "position": 0}],
description="The user wanted over-ear headphones; most results were earbuds.",
)
Pass source="eval" on feedback from a test suite or benchmark run, so it
stays apart from real traffic.
Before you filter a search, client.search.filter_values(org.id, "products")
lists the values each filterable field holds. client.usage.get(org.id) shows
where the organization stands against its plan's storage cap.
The async client mirrors this exactly:
from relevan import AsyncClient
async with AsyncClient() as client:
org = (await client.organizations.list())[0]
results = await client.search.search(org.id, "products", query="wireless headphones")
Authentication
Client() and AsyncClient() read the API key from the RELEVAN_API_KEY
environment variable by default — the same variable used elsewhere for
this API — or accept it directly: Client(api_key="relevan_..."). The key
is never written to disk or logged, and is masked in repr(client).
Integration name
Each request sends an X-Relevan-Integration header, python/<version> by
default. Relevan records it on search and feedback events, so it can count
the traffic of each integration. A library built on this client passes its
own name and version:
client = Client(integration="hermes/0.1.0")
The value is <name>/<version> in lower-case letters, digits, ., _, -
(and + in the version), at most 64 characters. The API ignores a value in
another form. It is a label, not a credential.
Rate limits
Relevan enforces per-organization rate limits. On a 429, the client
retries automatically using the server's Retry-After value
(max_retries=2 by default, configurable via Client(max_retries=...)).
A RelevanRateLimitError is raised only if retries are exhausted.
After each client.search.search(...) call, client.search.last_rate_limit
holds the org's current RateLimit-* snapshot (.limit, .remaining,
.reset_seconds), so callers can self-throttle proactively if they want to.
Beta endpoints
Endpoints under the API's /v1-beta path are exposed under client.beta
and documented as beta in their docstrings. Their contract may change
without warning — each call emits a RelevanBetaWarning so this is
visible at the call site, not just in documentation.
import warnings
warnings.simplefilter("once", category=None) # or filter RelevanBetaWarning specifically
Integrations
integrations/ holds plugins that use this client inside other tools. Each
has its own README and its own dependencies.
integrations/hermes_relevan: a memory provider for Hermes Agent, with feedback on the results each reply used.
Regenerating the client
src/relevan/_generated/ is generated from the live OpenAPI spec and is
never hand-edited:
uv run scripts/generate_client.py --url https://api.dev.relevan.dev/openapi
See that script's docstring for the spec normalization it applies and why.
Development
uv sync --extra dev
uv run ruff check .
uv run mypy src
uv run pytest
Releasing
Releases go to PyPI from the Publish workflow through trusted publishing,
so the repository stores no PyPI token.
- Set
versioninpyproject.tomland add aCHANGELOG.mdsection for it. - Merge to
main. - Tag the merge commit
v<version>and push the tag. The workflow fails if the tag andpyproject.tomldisagree.
License
Apache-2.0
Metadata
Release files for relevan 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| relevan-0.2.0.tar.gz | 65.2 kB | With provenance | Details for relevan-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| relevan-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for relevan-0.2.0-py3-none-any.whl |
Total release size: 205.0 kB
Release files / relevan-0.2.0.tar.gz
| Download URL | relevan-0.2.0.tar.gz |
|---|---|
| Size | 65.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5a4992837d8d2e46d51e274d1c010dd04113b65b4fe5ae776a10e0c75098912
|
|
BLAKE2b-256 checksum How to use checksums |
bb3e30cf1c61dd8f04990cfdf7d12b0b32eb592fbb6794b0e355c467e97909f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logRelease files / relevan-0.2.0-py3-none-any.whl
| Download URL | relevan-0.2.0-py3-none-any.whl |
|---|---|
| Size | 139.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea92029d975df4a02560f92ac50c37a0f98eb148644d5801cc1218dfa65262c4
|
|
BLAKE2b-256 checksum How to use checksums |
9e5def466609ee81f149b1fa671069de27816cf0259c5b9b4daf0a679b042bfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logSecurity for relevan 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for relevan-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.