Documentation
¶
Overview ¶
Package iris provides convenience functions for creating LLM clients.
This package provides one-liner factory functions for the most common use cases:
// Create an OpenAI client from environment variable
client, err := iris.OpenAI()
if err != nil {
log.Fatal(err)
}
// Auto-detect provider from available environment variables
client, err := iris.FromEnv()
For more control, use the provider packages directly:
provider := openai.New(apiKey, openai.WithBaseURL(customURL)) client := core.NewClient(provider)
Index ¶
- Variables
- func Anthropic() (*core.Client, error)
- func FromEnv() (*core.Client, error)
- func Gemini() (*core.Client, error)
- func MustAnthropic() *core.Client
- func MustFromEnv() *core.Client
- func MustGemini() *core.Client
- func MustOpenAI() *core.Client
- func Ollama() (*core.Client, error)
- func OpenAI() (*core.Client, error)
- func XAI() (*core.Client, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoAPIKey = errors.New("no API key found in environment")
ErrNoAPIKey is returned when no API key is found in environment variables.
Functions ¶
func Anthropic ¶
Anthropic creates a client using the ANTHROPIC_API_KEY environment variable.
Example:
client, err := iris.Anthropic()
if err != nil {
log.Fatal(err)
}
resp, _ := client.Chat("claude-sonnet-4-5").User("Hello!").GetResponse(ctx)
func FromEnv ¶
FromEnv auto-detects the provider from available environment variables. It checks for API keys in this order:
- OPENAI_API_KEY → OpenAI
- ANTHROPIC_API_KEY → Anthropic
- GEMINI_API_KEY or GOOGLE_API_KEY → Gemini
- XAI_API_KEY → XAI
If no API key is found, it returns ErrNoAPIKey.
Example:
client, err := iris.FromEnv()
if err != nil {
log.Fatal(err)
}
func Gemini ¶
Gemini creates a client using the GEMINI_API_KEY or GOOGLE_API_KEY environment variable.
Example:
client, err := iris.Gemini()
if err != nil {
log.Fatal(err)
}
resp, _ := client.Chat("gemini-2.5-flash").User("Hello!").GetResponse(ctx)
func MustAnthropic ¶
MustAnthropic creates an Anthropic client or panics if the API key is not set.
func MustFromEnv ¶
MustFromEnv creates a client from environment or panics if no API key is found.
func MustGemini ¶
MustGemini creates a Gemini client or panics if the API key is not set.
func MustOpenAI ¶
MustOpenAI creates an OpenAI client or panics if the API key is not set. Use this for simple scripts where error handling is not needed.
func Ollama ¶
Ollama creates a client for a local Ollama instance. No API key is required for local Ollama.
Example:
client, err := iris.Ollama()
if err != nil {
log.Fatal(err)
}
resp, _ := client.Chat("llama3.2").User("Hello!").GetResponse(ctx)
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli implements the Iris command-line interface.
|
Package cli implements the Iris command-line interface. |
|
commands
Package commands implements the CLI command tree and runtime wiring.
|
Package commands implements the CLI command tree and runtime wiring. |
|
config
Package config handles CLI configuration loading and management.
|
Package config handles CLI configuration loading and management. |
|
keystore
Package keystore provides secure storage for API keys.
|
Package keystore provides secure storage for API keys. |
|
cmd
|
|
|
gen-models
command
Command gen-models generates model constants from models.dev or local TOML files.
|
Command gen-models generates model constants from models.dev or local TOML files. |
|
iris
command
Iris CLI - command-line interface for the Iris SDK.
|
Iris CLI - command-line interface for the Iris SDK. |
|
releasecheck
command
Command releasecheck validates release inputs before artifacts are published.
|
Command releasecheck validates release inputs before artifacts are published. |
|
Package core provides the Iris SDK client and types.
|
Package core provides the Iris SDK client and types. |
|
internal
|
|
|
gen/models
Package models provides a code generator for model constants from models.dev.
|
Package models provides a code generator for model constants from models.dev. |
|
Package iristest provides test utilities for the Iris SDK.
|
Package iristest provides test utilities for the Iris SDK. |
|
Package providers contains LLM provider implementations for Iris.
|
Package providers contains LLM provider implementations for Iris. |
|
anthropic
Package anthropic provides an Anthropic API provider implementation for Iris.
|
Package anthropic provides an Anthropic API provider implementation for Iris. |
|
azurefoundry
Package azurefoundry provides an Iris provider implementation for Azure AI Foundry.
|
Package azurefoundry provides an Iris provider implementation for Azure AI Foundry. |
|
gemini
Package gemini provides a Google Gemini API provider implementation for Iris.
|
Package gemini provides a Google Gemini API provider implementation for Iris. |
|
huggingface
Package huggingface provides an LLM provider implementation for Hugging Face Inference Providers.
|
Package huggingface provides an LLM provider implementation for Hugging Face Inference Providers. |
|
internal/normalize
Package normalize provides shared provider error normalization helpers.
|
Package normalize provides shared provider error normalization helpers. |
|
internal/timeoutx
Package timeoutx applies per-provider timeouts to direct (non-chat) calls.
|
Package timeoutx applies per-provider timeouts to direct (non-chat) calls. |
|
internal/toolcalls
Package toolcalls provides shared streaming tool-call assembly utilities.
|
Package toolcalls provides shared streaming tool-call assembly utilities. |
|
ollama
Package ollama provides an Ollama provider implementation for the Iris SDK.
|
Package ollama provides an Ollama provider implementation for the Iris SDK. |
|
openai
Package openai provides an OpenAI API provider implementation for Iris.
|
Package openai provides an OpenAI API provider implementation for Iris. |
|
perplexity
Package perplexity provides a Perplexity Search API provider implementation for Iris.
|
Package perplexity provides a Perplexity Search API provider implementation for Iris. |
|
voyageai
Package voyageai provides a Voyage AI API provider implementation for Iris.
|
Package voyageai provides a Voyage AI API provider implementation for Iris. |
|
xai
Package xai provides an xAI Grok API provider implementation for Iris.
|
Package xai provides an xAI Grok API provider implementation for Iris. |
|
zai
Package zai provides a Z.ai GLM API provider implementation for Iris.
|
Package zai provides a Z.ai GLM API provider implementation for Iris. |
|
Package tools provides tool interfaces, registry, and argument parsing for AI tool calling.
|
Package tools provides tool interfaces, registry, and argument parsing for AI tool calling. |