Skip to main content

Infrastructure for efficient and scalable AI applications.

Project description

ai-infra

Production-ready Python SDK for building AI applications with LLMs, agents, and multimodal capabilities.

ai-infra provides clean interfaces for chat, agents, embeddings, voice, and image generation across 10+ providers—all with zero-config defaults.

✨ Features

  • LLM: Chat, structured output, streaming, retries, multi-turn conversations
  • Agents: Tool calling, human-in-the-loop, provider fallbacks, autonomous deep mode
  • Graph: LangGraph workflows with typed state and conditional branching
  • Embeddings & RAG: Vector storage, document retrieval, multiple backends
  • Multimodal: Text-to-speech, speech-to-text, vision, realtime voice
  • Image Generation: DALL-E, Imagen, Stability AI, Replicate
  • MCP: Model Context Protocol client/server, OpenAPI→MCP conversion

🚀 Quick Start

5 lines to your first chat:

from ai_infra import LLM

llm = LLM()  # Auto-detects configured provider
response = llm.chat("What is the capital of France?")
print(response)

With tools (agent):

from ai_infra import Agent

def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Weather in {city}: 72°F, sunny"

agent = Agent(tools=[get_weather])
result = agent.run("What's the weather in Tokyo?")
print(result)

📦 Installation

Python: 3.11 – 3.13

# Using pip
pip install ai-infra

# Using Poetry (development)
poetry install
poetry shell

🔑 Provider Setup

Set API keys for the providers you want to use:

# Required: At least one chat provider
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
export GOOGLE_API_KEY=...
export XAI_API_KEY=...

# Optional: Specialized providers
export ELEVENLABS_API_KEY=...     # TTS
export DEEPGRAM_API_KEY=...       # STT
export STABILITY_API_KEY=...      # Image generation
export REPLICATE_API_TOKEN=...    # Image generation
export VOYAGE_API_KEY=...         # Embeddings
export COHERE_API_KEY=...         # Embeddings

🔌 Supported Providers

Provider Chat Embeddings TTS STT ImageGen Realtime
OpenAI
Anthropic - - - - -
Google
xAI - - - - -
ElevenLabs - - - - -
Deepgram - - - - -
Stability - - - - -
Replicate - - - - -
Voyage - - - - -
Cohere - - - - -

📚 Documentation

Full documentation is in the docs/ folder:

Section Description
Getting Started Installation, API keys, first example
Core Modules LLM, Agent, Graph, Providers
Multimodal TTS, STT, Vision, Realtime Voice
Embeddings & RAG Embeddings, VectorStore, Retriever
Tools Schema tools, progress streaming
MCP Model Context Protocol client/server
Advanced Features Personas, Replay, Workspace, Deep Agent
Image Generation DALL-E, Imagen, Stability, Replicate
Infrastructure Errors, Logging, Tracing, Callbacks
CLI Reference Command-line interface

📁 Module Overview

Module Description
ai_infra.llm LLM chat, agents, structured output, streaming
ai_infra.graph LangGraph workflows with typed state
ai_infra.mcp MCP client/server, OpenAPI→MCP conversion
ai_infra.embeddings Text embeddings across providers
ai_infra.retriever RAG with multiple vector store backends
ai_infra.imagegen Image generation (DALL-E, Stability, etc.)
ai_infra.providers Centralized provider registry

🧪 Examples

See the examples/ folder for runnable scripts:

# LLM chat
python -c "from ai_infra.llm.examples.02_llm_chat_basic import main; main()"

# Agent with tools
python -c "from ai_infra.llm.examples.01_agent_basic import main; main()"

# Graph workflow
python -c "from ai_infra.graph.examples.01_graph_basic import main; main()"

# MCP client
python -m ai_infra.mcp.examples.01_mcps

🛠️ Development

# Install dev dependencies
poetry install

# Run tests
pytest -q

# Lint
ruff check src tests

# Type check
mypy src

# Format
ruff format

📄 License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_infra-0.1.112.tar.gz (276.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_infra-0.1.112-py3-none-any.whl (362.8 kB view details)

Uploaded Python 3

File details

Details for the file ai_infra-0.1.112.tar.gz.

File metadata

  • Download URL: ai_infra-0.1.112.tar.gz
  • Upload date:
  • Size: 276.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ai_infra-0.1.112.tar.gz
Algorithm Hash digest
SHA256 b1001ec4d1d50230c28e32c8d0ae0bb6e99696d55e2c7ca4764717f3bdcf9e58
MD5 1f82532deb49740ba0dd8995941463c6
BLAKE2b-256 f5770f201a18fd30072e30b97486b26d1e067b8bfcd81414ace922992eba72a1

See more details on using hashes here.

File details

Details for the file ai_infra-0.1.112-py3-none-any.whl.

File metadata

  • Download URL: ai_infra-0.1.112-py3-none-any.whl
  • Upload date:
  • Size: 362.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ai_infra-0.1.112-py3-none-any.whl
Algorithm Hash digest
SHA256 a8fdbd08ddd3772815a42fe90ebee8915455da3e5a620fea083fea793d48a7e1
MD5 0bdfcd8ea7e3c6f0ff727e2f5506b0de
BLAKE2b-256 ca55cd3307ccf6a00c3e9750d9850d39d5cf29718d2e3036c3e1efb2bf2f8358

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page