🎉 ai-infra v1.0 is here — Production-ready AI/LLM infrastructure
What's new
nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
ai-infra / API Reference

LLM

from ai_infra.llm import LLM
View source
ai_infra.llm
Extends:BaseLLM

Direct model convenience interface (no agent graph). The LLM class provides a simple API for chat-based interactions with language models. Use this when you don't need tool calling. Example - Basic usage:

python
llm = LLM()
    response = llm.chat("What is the capital of France?")
    print(response.content)  # "Paris is the capital of France."

Example - With structured output:

python
from pydantic import BaseModel

    class Answer(BaseModel):
        city: str
        country: str

    llm = LLM()
    result = llm.chat(
        "What is the capital of France?",
        output_schema=Answer,
    )
    print(result.city)  # "Paris"

Example - Streaming tokens:

python
llm = LLM()
    async for token, meta in llm.stream_tokens("Tell me a story"):
        print(token, end="", flush=True)
Constructor
LLM(callbacks: Callbacks | (CallbackManager | None) = None)
ParameterTypeDefaultDescription
callbacksCallbacks | (CallbackManager | None)NoneCallback handler(s) for observing LLM events. Receives events for LLM calls (start, end, error, tokens). Can be a single Callbacks instance or a CallbackManager.

Methods

On This Page

Constructorachatasyncchatis_provider_configuredstaticlist_all_modelsstaticlist_configured_providersstaticlist_modelsstaticlist_providersstaticstream_tokensasync