API Reference lemon_ai v#0.1.0

View Source

Modules

Provider-agnostic LLM client: one API for 27 providers.

OTP Application for the AI module.

Anthropic OAuth helpers for Claude subscription-backed access.

GitHub Copilot OAuth helpers.

Google Antigravity OAuth helpers.

Google Gemini CLI OAuth helpers.

Provider-agnostic OAuth secret resolver.

OpenAI Codex OAuth helpers.

Central dispatcher for routing AI provider requests through rate limiting and circuit breaking infrastructure.

Circuit breaker GenServer for managing per-provider failure states.

AI client with automatic context compaction and retry on ContextLengthExceeded.

Automatic context compaction for handling ContextLengthExceeded errors.

Environment variables read by ai — provider credentials, endpoints, and model-client tuning.

Error handling utilities for AI provider responses.

Async event stream for streaming LLM responses with OTP-compliant lifecycle management.

Caches model availability per provider using ETS to reduce redundant API calls. Ported from Oh-My-Pi's model-cache.ts (SQLite) to idiomatic Elixir with ETS.

Registry of known AI models with their capabilities and pricing.

Model definitions for the AmazonBedrock provider.

Model definitions for the Anthropic provider.

Model definitions for the AzureOpenAI provider.

Model definitions for the Cerebras provider.

Model definitions for the DeepSeek provider.

Model definitions for the Fireworks AI provider.

Model definitions for the GitHubCopilot provider.

Model definitions for the Google provider.

Model definitions for the GoogleGeminiCLI provider.

Model definitions for the GoogleVertex provider.

Model definitions for the Groq provider.

Model definitions for the HuggingFace provider.

Model definitions for the Kimi provider.

Model definitions for the KimiCoding provider.

Model definitions for the MiniMax provider.

Model definitions for the MiniMaxCN provider.

Model definitions for the Mistral provider.

Model definitions for the OpenAI provider.

Model definitions for the OpenCode provider.

Model definitions for the OpenCode Go provider.

Model catalog for the OpenRouter provider — a compile-time @models data map, one entry per model, carrying capability and per-million-token pricing metadata (LemonAi.Types.Model / LemonAi.Types.ModelCost). This is data, not logic: the module is long because the catalog is long.

Model definitions for the Qwen provider.

Model catalog for the Vercel AI Gateway provider — a compile-time @models data map, one entry per model, carrying capability and per-million-token pricing metadata (LemonAi.Types.Model / LemonAi.Types.ModelCost). This is data, not logic: the module is long because the catalog is long.

Model definitions for the XAI provider.

Model definitions for the ZAI provider.

Lightweight, opt-in diagnostics for prompt size + token usage.

Behaviour for LLM provider implementations.

Registry for LLM provider implementations.

DynamicSupervisor for per-provider services.

Anthropic Messages API provider implementation.

Shared helper for building the initial %AssistantMessage{} used by all streaming providers.

Azure OpenAI Responses API provider.

Amazon Bedrock Converse Stream API provider.

Google Generative AI (AI Studio) provider.

Google Gemini CLI / Cloud Code Assist provider.

Shared utilities for Google Generative AI, Vertex AI, and Gemini CLI providers.

Google Vertex AI provider.

HTTP request/response tracing utilities for AI provider integrations.

Mistral Conversations API provider.

OpenAI Codex Responses API provider (ChatGPT Plus/Pro).

OpenAI Completions API provider.

OpenAI Responses API provider.

Shared utilities for OpenAI Responses API family.

Shared retry utilities for AI provider implementations.

Shared SSE (Server-Sent Events) stream parser for OpenAI-compatible providers.

Shared helper for the identical stream/3 setup pattern across all AI providers.

Sanitizes text for safe use with AI providers.

Token bucket rate limiter GenServer for managing per-provider request rates.

Generic text truncation primitives.

Fast token estimation helpers.

Core type definitions for the AI library.

A message from the assistant/model

Conversation context containing messages, tools, and system prompt

Cost breakdown in dollars

Base64-encoded image content block

Model definition with capabilities and pricing

Cost per million tokens for a model

Options for streaming requests

Plain text content block

Model reasoning/thinking content block

Tool/function definition for the model

Tool/function call from the model

Result of a tool call

Token usage and cost for a response

A message from the user

Mix Tasks

List known Lemon AI models.