Basic Usage
Model Configuration
Each provider has its own configuration class.
OpenAI
Requires
Install "llmfy[openai]" and OPENAI_API_KEY environment variable.
from llmfy import OpenAIConfig
config = OpenAIConfig(temperature=0.7)
AWS Bedrock
Requires
Install "llmfy[boto3]" and AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_BEDROCK_REGION environment variables.
from llmfy import BedrockConfig
config = BedrockConfig(temperature=0.7)
Google AI
Requires
Install "llmfy[google-genai]" and GOOGLE_API_KEY environment variable.
from llmfy import GoogleAIConfig
config = GoogleAIConfig(temperature=0.7)
Initialize Model
OpenAI
from llmfy import OpenAIModel
llm = OpenAIModel(model="gpt-4o-mini", config=config)
AWS Bedrock
from llmfy import BedrockModel
llm = BedrockModel(model="amazon.nova-lite-v1:0", config=config)
Google AI
from llmfy import GoogleAIModel
llm = GoogleAIModel(model="gemini-2.5-flash-lite", config=config)
Create Agent
The LLMfy class is provider-agnostic — pass any initialized model:
from llmfy import LLMfy
agent = LLMfy(llm, system_message="You are a helpful assistant.")
Generate
Using Invoke
invoke accepts plain text or a list of Content objects:
response = agent.invoke("Hello")
print(f"\n>> {response.result.content}\n")
Using Chat
chat accepts a list of Message objects with roles:
from llmfy import Message, Role
messages = [Message(role=Role.USER, content="Hello")]
response = agent.chat(messages)
print(f"\n>> {response.result.content}\n")