Observed since 21 Oct, 11:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Infrastructure for efficient and scalable AI applications.
Build AI applications in minutes, not months.
One unified SDK for LLMs, agents, RAG, voice, images, and MCP—across 10+ providers.
Building AI apps means juggling OpenAI, Anthropic, Google, embeddings, vector stores, tool calling, MCP servers... each with different APIs and gotchas.
ai-infra gives you one clean interface that works everywhere:
from ai_infra import Agent
def search_web(query: str) -> str:
"""Search the web."""
return f"Results for: {query}"
agent = Agent(tools=[search_web])
result = agent.run("Find the latest news about AI")
# Works with OpenAI, Anthropic, Google—same code.
pip install ai-infra
| Feature | What You Get | One-liner |
|---|---|---|
| LLM Chat | Chat, streaming, structured output, retries | LLM().chat("Hello") |
| Agents | Tool calling, human-in-the-loop, deep mode | Agent(tools=[...]).run(...) |
| RAG | Embeddings, vector stores, retrieval | Retriever().search(...) |
| MCP | Client/server, OpenAPI->MCP, tool discovery | MCPClient(url) |
| Voice | Text-to-speech, speech-to-text, realtime | TTS().speak(...) |
| Images | DALL-E, Stability, Imagen generation | ImageGen().generate(...) |
| Graph | LangGraph workflows, typed state | Graph().add_node(...) |
| Memory | Context fitting, rolling summaries | fit_context(messages, max_tokens=4000) |
| Workspace | Sandboxed file operations for agents | Workspace("./project") |
| Validation | Prompt injection, PII detection | validate_prompt(input) |
| Tracing | OpenTelemetry distributed tracing | configure_tracing(...) |
from ai_infra import LLM
llm = LLM() # Uses OPENAI_API_KEY by default
response = llm.chat("Explain quantum computing in one sentence")
print(response)
# Switch providers instantly
llm = LLM(provider="anthropic", model="claude-sonnet-4-20250514")
response = llm.chat("Same question, different model")
from ai_infra import Agent
def get_weather(city: str) -> str:
"""Get current weather for a city."""
return f"72F and sunny in {city}"
def search_web(query: str) -> str:
"""Search the web for information."""
return f"Top results for: {query}"
agent = Agent(tools=[get_weather, search_web])
result = agent.run("What's the weather in Tokyo and find me restaurants there")
# Agent automatically calls both tools and synthesizes the answer
from ai_infra import Retriever
retriever = Retriever()
retriever.add_file("company_docs.pdf")
retriever.add_file("product_manual.md")
results = retriever.search("How do I reset my password?")
print(results[0].content)
from ai_infra import MCPClient
async with MCPClient("http://localhost:8080") as client:
tools = await client.list_tools()
result = await client.call_tool("search", {"query": "AI news"})
from ai_infra import mcp_from_functions
def search_docs(query: str) -> str:
"""Search documentation."""
return f"Found: {query}"
mcp = mcp_from_functions(name="my-mcp", functions=[search_docs])
mcp.run(transport="stdio")
| Provider | Chat | Embeddings | TTS | STT | Images | Realtime |
|---|---|---|---|---|---|---|
| OpenAI | Yes | Yes | Yes | Yes | Yes | Yes |
| Anthropic | Yes | - | - | - | - | - |
| Yes | Yes | Yes | Yes | Yes | Yes | |
| xAI (Grok) | Yes | - | - | - | - | - |
| ElevenLabs | - | - | Yes | - | - | - |
| Deepgram | - | - | - | Yes | - | - |
| Stability AI | - | - | - | - | Yes | - |
| Replicate | - | - | - | - | Yes | - |
| Voyage AI | - | Yes | - | - | - | - |
| Cohere | - | Yes | - | - | - | - |
# Set your API keys (use whichever providers you need)
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
export GOOGLE_API_KEY=...
# That's it. ai-infra auto-detects available providers.
For complex, multi-step tasks:
from ai_infra import DeepAgent
agent = DeepAgent(
goal="Analyze this codebase and generate documentation",
tools=[read_file, write_file, search],
max_iterations=50,
)
result = await agent.run()
print(result.output)
Includes: Planning, self-correction, progress tracking, human approval gates.
Advanced MCP features:
from ai_infra import MCPClient
from ai_infra.mcp import RetryInterceptor, CachingInterceptor, LoggingInterceptor
async with MCPClient(
"http://localhost:8080",
interceptors=[
RetryInterceptor(max_retries=3),
CachingInterceptor(ttl=300),
LoggingInterceptor(),
]
) as client:
# Automatic retries, caching, and logging for all tool calls
result = await client.call_tool("expensive_operation", {...})
Includes: Callbacks, interceptors, prompts, resources, progress tracking.
from ai_infra import Retriever
# In-memory (development)
retriever = Retriever(backend="memory")
# SQLite (local persistence)
retriever = Retriever(backend="sqlite", path="./vectors.db")
# PostgreSQL with pgvector (production)
retriever = Retriever(backend="postgres", connection_string="...")
# Pinecone (managed cloud)
retriever = Retriever(backend="pinecone", index_name="my-index")
from ai_infra import TTS, STT
# Text to speech
tts = TTS(provider="elevenlabs")
audio = tts.speak("Hello, world!")
# Speech to text
stt = STT(provider="deepgram")
text = stt.transcribe("audio.mp3")
from ai_infra import ImageGen
gen = ImageGen(provider="openai") # or "stability", "replicate"
image = gen.generate("A futuristic city at sunset")
image.save("city.png")
# Test MCP connections
ai-infra mcp test --url http://localhost:8080
# List MCP tools
ai-infra mcp tools --url http://localhost:8080
# Call an MCP tool
ai-infra mcp call --url http://localhost:8080 --tool search --args '{"query": "test"}'
# Server info
ai-infra mcp info --url http://localhost:8080
| Section | Description |
|---|---|
| Getting Started | Installation, API keys, first example |
| Core | |
| LLM | Chat, streaming, structured output |
| Agent | Tool calling, human-in-the-loop |
| Graph | LangGraph workflows |
| RAG & Embeddings | |
| Retriever | Vector search, file loading |
| Embeddings | Text embeddings |
| MCP | |
| Client | Connect to MCP servers |
| Server | Create MCP servers |
| Multimodal | |
| TTS | Text-to-speech |
| STT | Speech-to-text |
| Vision | Image understanding |
| Advanced | |
| Deep Agent | Autonomous agents |
| Personas | Agent personalities |
| Workspace | Sandboxed file operations |
| Memory | Context management, rolling summaries |
| Streaming | Typed streaming events |
| Infrastructure | |
| Validation | Prompt/response validation |
| Tracing | OpenTelemetry tracing |
| Callbacks | Execution hooks |
| CLI Reference | Command-line tools |
git clone https://github.com/nfraxlab/ai-infra.git
cd ai-infra
poetry install
# Chat
poetry run python -c "from ai_infra import LLM; print(LLM().chat('Hello!'))"
# Agent
poetry run python examples/agents/01_basic_tools.py
# See more examples
ls examples/
ai-infra is part of the nfrax infrastructure suite:
| Package | Purpose |
|---|---|
| ai-infra | AI/LLM infrastructure (agents, tools, RAG, MCP) |
| svc-infra | Backend infrastructure (auth, billing, jobs, webhooks) |
| fin-infra | Financial infrastructure (banking, portfolio, insights) |
MIT License - use it for anything.
Built by nfraxlab
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.19.0 | 25 Aug 2026 | 30 |
This describes our collected data; it is not a security assessment.
Observed since 21 Oct, 11:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d675727b6ec4dcb45a80a1362f0ac601e2af79e85ddc593f75619bce9e45ae05