Skip to main content
The Python and TypeScript SDKs wrap every endpoint in the API Reference with typed methods. They set the API-Version: 2 header on every request. For a first end-to-end run, follow the Quickstart.

Installation

Install version 2 of the Python or TypeScript SDK:

Client setup

The Python SDK has a synchronous client (HydraDB) and an asynchronous one (AsyncHydraDB). They expose the same methods; use AsyncHydraDB with await.

Naming conventions

The REST API and the Python SDK use snake_case. The TypeScript SDK uses camelCase for multi-word method names and for fields in typed request and response objects. In TypeScript:
  • Typed fields are camelCase only. Use client.context.list({ database: "...", pageSize: 50 }). The SDK sends page_size to the API and drops unrecognized typed fields, including a caller-supplied page_size.
  • JSON strings and free-form maps are sent as written. Inside JSON strings (documentMetadata, memories, appKnowledge) and free-form maps (metadataFilters, and in Python a connector resource update’s request), use REST field names such as additional_metadata or custom_instructions, and preserve your own metadata keys.
  • Response fields are camelCase and optional in the types. Read them as status.data?.infra?.readyForIngestion.
database and collection are the current field names. The former names, tenant_id and sub_tenant_id, are still accepted as deprecated aliases. See Databases and Collections.

Method reference

Methods are grouped under one namespace per API group: client.context, client.databases, client.connectors, client.webhooks, and client.feedback. client.query() and client.list_providers() sit on the client itself. The tables use the Python method names. TypeScript uses camelCase for multi-word ones (list_resources() is listResources()).

Context

client.context.* manages stored context: ingestion, indexing status, listing, inspection, metadata updates, deletion, and graph relations.

Query

One method covers every query. Set type ("knowledge", "memory", "all") and query_by ("hybrid", "text") to control it.

Feedback

Databases

The legacy /tenants/* paths remain available as deprecated aliases of /databases/*.

Connectors

Webhooks

Common calls

These examples show the SDK call shape for each step of an integration, in both languages. The Quickstart explains the flow end to end.

Create a database

Database creation is asynchronous. Poll databases.status until provisioning completes:

Ingest knowledge

Upload files, ingest app sources, or do both in one call. document_metadata is a JSON string with one entry per file:
For app sources (Slack, Notion, Gmail, webpages), pass app_knowledge instead of documents, or pass both in one request. See Ingest Context.

Ingest memories

Use the same ingest method with type: "memory":
infer defaults to false, which stores the text verbatim. Set infer: true for conversational content where you want HydraDB to extract implicit preferences.

Wait for indexing

Sources are searchable only after indexing. Check each collection separately, using the IDs supplied at ingestion or returned in data.results.

Run queries

Three common shapes of client.query():
For the full parameter reference, see Query.

List, inspect, and delete

Response envelope

All responses, except those from connector endpoints and PATCH /databases/{database}/metadata-schema, are wrapped in the response envelope:
The SDKs return the full envelope. Read the payload from the data field (for example, response.data). On failure, the SDK raises a typed exception; it does not return an envelope with error populated.

Model names in the API reference

The API reference displays the SDK model names for named objects across endpoints. Expand Show child attributes to see each model’s fields. The object or object[] annotation alongside a model name describes its JSON representation, not an untyped SDK return value. The reference does not invent separate names such as Result object or Alias expansion.object. Python exposes these models from hydra_db.types; TypeScript exposes them in the HydraDB namespace from @hydradb/sdk. Python fields use snake_case (alias_expansions), while TypeScript fields use camelCase (aliasExpansions). Query data can also be a string when response_format is markdown, so narrow that union before reading structured fields. Maps you define, such as metadata and additional_metadata, allow arbitrary keys and values, so their contents have no fixed property autocomplete. The surrounding response and its known fields still have declared types. Improvements to the generated models reach you only when you install an SDK release that includes them.

Error handling

Both SDKs raise an exception for a non-2xx response. The exception exposes the envelope’s error payload:
The Python SDK raises a typed exception per status from hydra_db.errors. Each subclasses ApiError and carries status_code, headers, and the parsed response body, from which you can read body["error"]["code"]. Not every status has its own class: 401 and 429 do not. To handle those, catch the base ApiError and branch on status_code, as above. Both SDKs retry some failures automatically. See Error Responses for the retry rules and the full list of error codes.

Migrating from v1

Common method changes from v1 to v2: The v1 SDK methods remain available on the <2.0.0 releases of hydradb-sdk / @hydradb/sdk for as long as v1 routes are supported.