Installation

This page covers all the ways to install and configure the Ynfra SDK. Choose the method that fits your stack.

JavaScript / TypeScript

The TypeScript SDK is published as @ynfra/sdk on npm. It requires Node.js 18 or later (uses native fetch).

npm install @ynfra/sdk
# or
pnpm add @ynfra/sdk
# or
yarn add @ynfra/sdk

Python

The Python SDK is published as ynfra on PyPI. It requires Python 3.10 or later and uses httpx for async HTTP.

pip install ynfra

Optional Dependencies

Framework adapters have optional dependencies. Install only what you need:

pip install ynfra[openai]      # OpenAI Agents adapter
pip install ynfra[langgraph]   # LangGraph adapter
pip install ynfra[crewai]      # CrewAI adapter
pip install ynfra[autogen]     # AutoGen adapter
pip install ynfra[openclaw]    # OpenClaw adapter
pip install ynfra[all]         # All adapters

Configuration

The SDK resolves configuration in this order (first match wins):

  1. Constructor arguments passed directly to Ynfra() or wrap()
  2. Environment variables (YNFRA_API_KEY, YNFRA_BASE_URL)
  3. Config file (.ynfra.json in the project root)

Environment Variables

VariableDescriptionDefault
YNFRA_API_KEYYour API key (hx_live_* or hx_test_*)Required
YNFRA_BASE_URLAPI base URLhttps://api.ynfra.ai
YNFRA_SILENTSet to 1 to suppress console output0

Config File

Create a .ynfra.json in your project root:

{
  "apiKey": "hx_test_your_key_here",
  "baseUrl": "https://api.ynfra.ai"
}

Add .ynfra.json to your .gitignore to avoid committing API keys.

API Key Types

PrefixEnvironmentBillingUse For
hx_test_*TestNo billingDevelopment, CI, staging
hx_live_*ProductionBilledProduction workloads

Test and production environments are completely isolated. Data captured with a test key is never visible to production keys and vice versa.

Verifying Your Installation

TypeScript:

import { Ynfra } from '@ynfra/sdk'

const hx = new Ynfra()
const result = await hx.synthesize({ query: 'test' })
console.log('Connected:', result.ok)

Python:

import asyncio
from ynfra import Ynfra

async def main():
    hx = Ynfra()
    result = await hx.synthesize(query="test")
    print("Connected:", result.ok)

asyncio.run(main())

Next Steps