Skip to main content
Nia provides official SDKs for Python and TypeScript with a high-level client that wraps the REST API into an ergonomic interface with built-in retries, streaming, and type safety.

Installation

pip install nia-ai-py
Or with uv:
uv add nia-ai-py
Requires Python 3.10+.

Quick Start

from nia_py.sdk import NiaSDK

sdk = NiaSDK(api_key="nia_your_api_key")

# Semantic search across your indexed sources
results = sdk.search.universal(query="How does authentication work?")
print(results)
Get your API key at app.trynia.ai under Settings → API Keys. Never commit API keys to version control.

Core Concepts

The SDK is organized into three clients accessible from the main NiaSDK instance:
ClientDescription
sdk.searchSemantic search, web search, deep research, and query-based code search
sdk.sourcesCreate, list, resolve, and delete indexed sources (repos, docs, papers)
sdk.oracleLaunch autonomous research jobs with streaming and polling
from nia_py.sdk import NiaSDK

sdk = NiaSDK(api_key="nia_your_api_key")

# Universal search across all indexed sources
results = sdk.search.universal(query="implement retry logic", top_k=10)

# Query search with specific repos and conversation context
results = sdk.search.query(
    messages=[{"role": "user", "content": "How does streaming work?"}],
    repositories=["vercel/ai"],
)

# Web search
results = sdk.search.web(query="latest LLM developments")

# Deep research (multi-step with citations)
results = sdk.search.deep(query="Compare RSC vs traditional SSR")

Source Management

# Create a source (auto-detects type from URL)
sdk.sources.create({"url": "https://github.com/vercel/ai"})
sdk.sources.create({"url": "https://docs.anthropic.com"})

# List sources with filters
repos = sdk.sources.list(type="repository", limit=20)

# Resolve a source by name
source = sdk.sources.resolve(identifier="vercel/ai")

# Delete a source
sdk.sources.delete(source_id="source-uuid")

Oracle Research

Oracle is Nia’s autonomous research agent. It runs multi-step research jobs that can take minutes to complete.
# Start a research job
job = sdk.oracle.create_job(
    query="How does Next.js handle caching in the App Router?",
    repositories=["vercel/next.js"],
)
print(f"Job started: {job['id']}")

# Wait for completion (polls every 2s, 10min timeout)
result = sdk.oracle.wait_for_job(job_id=job["id"])
print(result)

# Or stream events in real-time
for event in sdk.oracle.stream_job_events(job_id=job["id"]):
    print(event)

Configuration

Both SDKs accept the same configuration options:
sdk = NiaSDK(
    api_key="nia_your_api_key",
    base_url="https://apigcp.trynia.ai/v2",  # default
    timeout_seconds=60.0,                      # request timeout
    max_retries=2,                             # retry on 5xx / transport errors
    initial_backoff_seconds=0.5,               # exponential backoff base
)

Next Steps

Authentication

API key setup, environment variables, and advanced client configuration

Examples

Complete code examples for all SDK operations

REST API Reference

Full REST API documentation with all endpoints

Get API Key

Create your free Nia account and generate an API key