A developer-friendly Lua interface for working with multiple generative AI providers, abstracting away provider-specific payload structures and response parsing so you can easily switch between various models and providers without rewriting any code.
- Easily switch between AI chat model providers.
- Pass in prompts and get replies without the provider complexity.
- Easily integrate new models and adjust settings.
- Work directly with the
src.ai
client for more granular control.
local AI = require("src.ai")
local Chat = require("src.chat")
local api_key = "<YOUR_API_KEY>"
local endpoint = "https://api.openai.com/v1/chat/completions"
local model = "gpt-4o-mini"
local system_prompt = "You are the king of a nation."
local ai = AI.new(api_key, endpoint)
local chat = Chat.new(ai, model, system_prompt)
local reply = chat:say("Give three short words of advice to the hero.")
print(reply)
See main.lua
for a more detailed example.
Streaming responses- Error handling
- Structured output
- Token cost tracking
- Gemini and open-source model integration
- Image models
- Audio models