Iris Core Package
Entry points
Section titled “Entry points”client := core.NewClient(provider, core.WithTelemetry(hook), core.WithRetryPolicy(core.DefaultRetryPolicy()), core.WithWarningHandler(handler),)Key types
Section titled “Key types”| Type | Purpose |
|---|---|
Client | Provider wrapper that exposes Chat() and common workflows. Thread-safe. |
ChatBuilder | Fluent builder for chat requests. NOT thread-safe—use Clone(). |
MessageBuilder | Build multimodal messages with text, images, and files. |
ChatStream | Streaming response channels (Ch, Err, Final). |
ChatRequest / ChatResponse | Canonical request and response structures. |
Tool / ToolCall / ToolResult | Tool definitions, model call payloads, and results. |
Memory / InMemoryStore | Conversation memory interface and implementation. |
Conversation | High-level multi-turn conversation API. |
Secret | Wrap sensitive strings with automatic redaction. |
RetryPolicy / RetryConfig | Retry policy configuration. |
TelemetryHook | Request lifecycle events. |
Provider Interface
Section titled “Provider Interface”type Provider interface { ID() string // Provider identifier Models() []ModelInfo // Available models Supports(feature Feature) bool // Feature capability check Chat(ctx context.Context, req *ChatRequest) (*ChatResponse, error) StreamChat(ctx context.Context, req *ChatRequest) (*ChatStream, error)}Feature Constants
Section titled “Feature Constants”const ( FeatureChat Feature = "chat" FeatureChatStreaming Feature = "chat_streaming" FeatureToolCalling Feature = "tool_calling" FeatureReasoning Feature = "reasoning" FeatureBuiltInTools Feature = "built_in_tools" FeatureEmbeddings Feature = "embeddings" FeatureContextualizedEmbeddings Feature = "contextualized_embeddings" FeatureReranking Feature = "reranking")Core functions
Section titled “Core functions”func NewClient(p Provider, opts ...ClientOption) *Clientfunc WithTelemetry(h TelemetryHook) ClientOptionfunc WithRetryPolicy(r RetryPolicy) ClientOptionfunc WithWarningHandler(h WarningHandler) ClientOptionfunc DefaultRetryPolicy() RetryPolicyfunc NewRetryPolicy(cfg RetryConfig) RetryPolicyfunc DrainStream(ctx context.Context, s *ChatStream) (*ChatResponse, error)func NewSecret(value string) Secretfunc NewInMemoryStore() *InMemoryStorefunc NewConversation(client *Client, model string, opts ...ConversationOption) *ConversationChatBuilder (selected)
Section titled “ChatBuilder (selected)”func (c *Client) Chat(model string) *ChatBuilderfunc (b *ChatBuilder) System(text string) *ChatBuilderfunc (b *ChatBuilder) User(text string) *ChatBuilderfunc (b *ChatBuilder) Assistant(text string) *ChatBuilderfunc (b *ChatBuilder) Tools(tools ...Tool) *ChatBuilderfunc (b *ChatBuilder) ToolResults(results ...ToolResult) *ChatBuilderfunc (b *ChatBuilder) Temperature(v float64) *ChatBuilderfunc (b *ChatBuilder) MaxTokens(v int) *ChatBuilderfunc (b *ChatBuilder) Instructions(text string) *ChatBuilderfunc (b *ChatBuilder) ReasoningEffort(effort ReasoningEffort) *ChatBuilderfunc (b *ChatBuilder) WebSearch() *ChatBuilderfunc (b *ChatBuilder) FileSearch() *ChatBuilderfunc (b *ChatBuilder) CodeInterpreter() *ChatBuilderfunc (b *ChatBuilder) ResponseJSON() *ChatBuilderfunc (b *ChatBuilder) ResponseJSONSchema(schema *JSONSchemaDefinition) *ChatBuilderfunc (b *ChatBuilder) Timeout(d time.Duration) *ChatBuilderfunc (b *ChatBuilder) Stream(ctx context.Context) (*ChatStream, error)func (b *ChatBuilder) GetResponse(ctx context.Context) (*ChatResponse, error)func (b *ChatBuilder) Clone() *ChatBuilderStructured Output
Section titled “Structured Output”type JSONSchemaDefinition struct { Name string // Schema name for caching Description string // Optional description Strict bool // Enable strict validation Schema json.RawMessage // JSON Schema definition}MessageBuilder (selected)
Section titled “MessageBuilder (selected)”func (b *ChatBuilder) UserMultimodal() *MessageBuilderfunc (m *MessageBuilder) Text(text string) *MessageBuilderfunc (m *MessageBuilder) ImageURL(url string) *MessageBuilderfunc (m *MessageBuilder) ImageURLWithDetail(url string, detail string) *MessageBuilderfunc (m *MessageBuilder) ImageFileID(fileID string) *MessageBuilderfunc (m *MessageBuilder) FileURL(url string) *MessageBuilderfunc (m *MessageBuilder) FileID(fileID string) *MessageBuilderfunc (m *MessageBuilder) FileBase64(data, mimeType string) *MessageBuilderfunc (m *MessageBuilder) Done() *ChatBuilderMemory Interface
Section titled “Memory Interface”type Memory interface { AddMessage(msg Message) AddMessages(msgs []Message) GetHistory() []Message GetLastN(n int) []Message Clear() Len() int SetMessages(msgs []Message)}ToolCall and ToolResult
Section titled “ToolCall and ToolResult”type ToolCall struct { ID string // Unique call identifier Name string // Tool name Arguments json.RawMessage // JSON-encoded arguments}
type ToolResult struct { CallID string // Corresponds to ToolCall.ID Content any // Result content IsError bool // True if this is an error result}Secret Type
Section titled “Secret Type”type Secret struct { value string }
func NewSecret(value string) Secretfunc (s Secret) String() string // Returns "[REDACTED]"func (s Secret) Expose() string // Returns actual valuefunc (s Secret) IsEmpty() boolBatch API
Section titled “Batch API”// Check if provider supports batch operationsfunc AsBatchProvider(p Provider) (BatchProvider, bool)
type BatchProvider interface { CreateBatch(ctx context.Context, requests []BatchRequest) (string, error) GetBatchStatus(ctx context.Context, batchID string) (*BatchInfo, error) GetBatchResults(ctx context.Context, batchID string) ([]BatchResult, error) CancelBatch(ctx context.Context, batchID string) error ListBatches(ctx context.Context, limit int) ([]BatchInfo, error)}
type BatchRequest struct { CustomID string // Your identifier for the request Request ChatRequest // The chat request}
type BatchInfo struct { ID string // Batch identifier Status BatchStatus // Current status Total int // Total requests Completed int // Completed requests Failed int // Failed requests Error string // Error message if failed}
type BatchResult struct { CustomID string // Your identifier Response *ChatResponse // Response (if successful) Error *BatchError // Error (if failed)}
func (r *BatchResult) IsSuccess() bool
type BatchStatus stringconst ( BatchStatusPending BatchStatus = "pending" BatchStatusInProgress BatchStatus = "in_progress" BatchStatusCompleted BatchStatus = "completed" BatchStatusFailed BatchStatus = "failed" BatchStatusCancelled BatchStatus = "cancelled" BatchStatusExpired BatchStatus = "expired")
func (i *BatchInfo) IsComplete() bool
// BatchWaiter polls for batch completionfunc NewBatchWaiter(bp BatchProvider) *BatchWaiterfunc (w *BatchWaiter) WithPollInterval(d time.Duration) *BatchWaiterfunc (w *BatchWaiter) WithMaxWait(d time.Duration) *BatchWaiterfunc (w *BatchWaiter) Wait(ctx context.Context, batchID string) (*BatchInfo, error)func (w *BatchWaiter) WaitAndCollect(ctx context.Context, batchID string) ([]BatchResult, error)Conversation
Section titled “Conversation”func NewConversation(client *Client, model string, opts ...ConversationOption) *Conversation
type ConversationOption func(*Conversation)func WithSystemMessage(msg string) ConversationOption
func (c *Conversation) Send(content string) (*ChatResponse, error)func (c *Conversation) Stream(content string) (*ChatStream, error)func (c *Conversation) MessageCount() intfunc (c *Conversation) GetHistory() []Messagefunc (c *Conversation) Clear()Sentinel Errors
Section titled “Sentinel Errors”var ( ErrUnauthorized // Authentication failed ErrRateLimited // Rate limit exceeded ErrBadRequest // Malformed request ErrNotFound // Resource not found ErrServer // Provider server error ErrNetwork // Network connectivity error ErrDecode // Response decoding error ErrNotSupported // Feature not supported ErrModelRequired // Model parameter required ErrNoMessages // No messages in request)testing
Section titled “testing”The testing package provides utilities for deterministic testing of LLM code.
MockProvider
Section titled “MockProvider”func NewMockProvider() *MockProviderfunc (m *MockProvider) WithResponse(resp ChatResponse) *MockProviderfunc (m *MockProvider) WithDefaultResponse(resp ChatResponse) *MockProviderfunc (m *MockProvider) WithError(err error) *MockProviderfunc (m *MockProvider) WithStreamingResponse(chunks []string, final *ChatResponse) *MockProviderfunc (m *MockProvider) Calls() []MockCall
type MockCall struct { Method string // "Chat" or "StreamChat" Request *ChatRequest // The request made}RecordingProvider
Section titled “RecordingProvider”func NewRecordingProvider(provider Provider) *RecordingProviderfunc (r *RecordingProvider) Recordings() []Recordingfunc (r *RecordingProvider) Clear()
type Recording struct { Method string // "Chat" or "StreamChat" Request *ChatRequest // The request Response *ChatResponse // The response (if successful) Error error // The error (if failed) Duration time.Duration // How long the call took}