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) 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() *ChatBuilderMessageBuilder (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() boolSentinel 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)