Documentation
¶
Overview ¶
Package anyllm provides a unified interface for interacting with LLM providers.
This package re-exports common types and configuration options from subpackages, allowing most use cases to work with just two imports:
import (
anyllm "github.com/mozilla-ai/any-llm-go"
"github.com/mozilla-ai/any-llm-go/providers/openai"
)
provider, err := openai.New(anyllm.WithAPIKey("sk-..."))
response, err := provider.Completion(ctx, anyllm.CompletionParams{
Model: "gpt-4o-mini",
Messages: []anyllm.Message{
{Role: anyllm.RoleUser, Content: "Hello!"},
},
})
Index ¶
- Constants
- Variables
- type AuthenticationError
- type BaseError
- type Batch
- type BatchProvider
- type BatchRequestCounts
- type BatchRequestItem
- type BatchResult
- type BatchResultError
- type BatchResultItem
- type BatchStatus
- type Capabilities
- type CapabilityProvider
- type ChatCompletion
- type ChatCompletionChunk
- type Choice
- type ChunkChoice
- type ChunkDelta
- type CompletionParams
- type Config
- type ContentFilterError
- type ContentPart
- type ContextLengthError
- type CreateBatchParams
- type EmbeddingData
- type EmbeddingParams
- type EmbeddingProvider
- type EmbeddingResponse
- type EmbeddingUsage
- type Function
- type FunctionCall
- type ImageURL
- type InsufficientFundsError
- type InvalidRequestError
- type JSONSchema
- type ListBatchesOptions
- type Message
- type MissingAPIKeyError
- type Model
- type ModelLister
- type ModelNotFoundError
- type ModelsResponse
- type ModerationParams
- type ModerationProvider
- type ModerationResponse
- type ModerationResult
- type Option
- type Provider
- type ProviderError
- type RateLimitError
- type Reasoning
- type ReasoningEffort
- type RerankMeta
- type RerankParams
- type RerankProvider
- type RerankResponse
- type RerankResult
- type RerankUsage
- type ResponseFormat
- type StreamOptions
- type Tool
- type ToolCall
- type ToolChoice
- type ToolChoiceFunction
- type UnsupportedOperationError
- type UnsupportedParamError
- type UnsupportedProviderError
- type Usage
Constants ¶
const ( RoleAssistant = providers.RoleAssistant RoleSystem = providers.RoleSystem RoleTool = providers.RoleTool RoleUser = providers.RoleUser )
Message roles.
const ( FinishReasonContentFilter = providers.FinishReasonContentFilter FinishReasonLength = providers.FinishReasonLength FinishReasonStop = providers.FinishReasonStop FinishReasonToolCalls = providers.FinishReasonToolCalls )
Finish reasons.
const ( BatchStatusCancelled = providers.BatchStatusCancelled BatchStatusCancelling = providers.BatchStatusCancelling BatchStatusCompleted = providers.BatchStatusCompleted BatchStatusExpired = providers.BatchStatusExpired BatchStatusFailed = providers.BatchStatusFailed BatchStatusFinalizing = providers.BatchStatusFinalizing BatchStatusInProgress = providers.BatchStatusInProgress BatchStatusValidating = providers.BatchStatusValidating )
Batch status constants.
const ( ReasoningEffortAuto = providers.ReasoningEffortAuto ReasoningEffortHigh = providers.ReasoningEffortHigh ReasoningEffortLow = providers.ReasoningEffortLow ReasoningEffortMedium = providers.ReasoningEffortMedium ReasoningEffortNone = providers.ReasoningEffortNone )
ReasoningEffort levels.
Variables ¶
var ( NewConfig = config.New WithAPIKey = config.WithAPIKey WithBaseURL = config.WithBaseURL WithExtra = config.WithExtra WithHeader = config.WithHeader WithHTTPClient = config.WithHTTPClient WithTimeout = config.WithTimeout )
Configuration options.
var ( ErrAuthentication = errors.ErrAuthentication ErrContentFilter = errors.ErrContentFilter ErrContextLength = errors.ErrContextLength ErrInsufficientFunds = errors.ErrInsufficientFunds ErrInvalidRequest = errors.ErrInvalidRequest ErrMissingAPIKey = errors.ErrMissingAPIKey ErrModelNotFound = errors.ErrModelNotFound ErrProvider = errors.ErrProvider ErrRateLimit = errors.ErrRateLimit ErrUnsupported = errors.ErrUnsupported ErrUnsupportedParam = errors.ErrUnsupportedParam ErrUnsupportedProvider = errors.ErrUnsupportedProvider )
Sentinel errors for type checking with errors.Is().
Functions ¶
This section is empty.
Types ¶
type BatchRequestCounts ¶ added in v0.10.0
type BatchRequestCounts = providers.BatchRequestCounts
Batch types.
type BatchRequestItem ¶ added in v0.10.0
type BatchRequestItem = providers.BatchRequestItem
Batch types.
type BatchResultError ¶ added in v0.10.0
type BatchResultError = providers.BatchResultError
Batch types.
type BatchResultItem ¶ added in v0.10.0
type BatchResultItem = providers.BatchResultItem
Batch types.
type ChatCompletionChunk ¶
type ChatCompletionChunk = providers.ChatCompletionChunk
Request/Response types.
type CreateBatchParams ¶ added in v0.10.0
type CreateBatchParams = providers.CreateBatchParams
Batch types.
type EmbeddingResponse ¶
type EmbeddingResponse = providers.EmbeddingResponse
Request/Response types.
type InsufficientFundsError ¶ added in v0.10.0
type InsufficientFundsError = errors.InsufficientFundsError
Error types.
type ListBatchesOptions ¶ added in v0.10.0
type ListBatchesOptions = providers.ListBatchesOptions
Batch types.
type ModerationParams ¶ added in v0.10.0
type ModerationParams = providers.ModerationParams
Request/Response types.
type ModerationProvider ¶ added in v0.10.0
type ModerationProvider = providers.ModerationProvider
Provider types.
type ModerationResponse ¶ added in v0.10.0
type ModerationResponse = providers.ModerationResponse
Request/Response types.
type ModerationResult ¶ added in v0.10.0
type ModerationResult = providers.ModerationResult
Request/Response types.
type RerankProvider ¶ added in v0.10.0
type RerankProvider = providers.RerankProvider
Provider types.
type UnsupportedOperationError ¶ added in v0.10.0
type UnsupportedOperationError = errors.UnsupportedOperationError
Error types.
type UnsupportedProviderError ¶
type UnsupportedProviderError = errors.UnsupportedProviderError
Error types.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
Example: Basic completion request
|
Example: Basic completion request |
|
llamafile-tools
command
Example: Tool/Function calling with Llamafile
|
Example: Tool/Function calling with Llamafile |
|
multi-provider
command
Example: Multi-provider usage
|
Example: Multi-provider usage |
|
streaming
command
Example: Streaming responses
|
Example: Streaming responses |
|
tools
command
Example: Tool/Function calling
|
Example: Tool/Function calling |
|
internal
|
|
|
redirect
Package redirect keeps credentials on the origin the caller sent them to.
|
Package redirect keeps credentials on the origin the caller sent them to. |
|
testutil
Package testutil provides testing utilities and fixtures for any-llm.
|
Package testutil provides testing utilities and fixtures for any-llm. |
|
Package providers defines the core provider interface and related types.
|
Package providers defines the core provider interface and related types. |
|
anthropic
Package anthropic provides an Anthropic provider implementation for any-llm.
|
Package anthropic provides an Anthropic provider implementation for any-llm. |
|
deepseek
Package deepseek provides a DeepSeek provider implementation for any-llm.
|
Package deepseek provides a DeepSeek provider implementation for any-llm. |
|
gateway
Package gateway provides a gateway provider implementation for any-llm.
|
Package gateway provides a gateway provider implementation for any-llm. |
|
gemini
Package gemini provides a Google Gemini provider implementation for any-llm.
|
Package gemini provides a Google Gemini provider implementation for any-llm. |
|
groq
Package groq provides a Groq provider implementation for any-llm.
|
Package groq provides a Groq provider implementation for any-llm. |
|
llamacpp
Package llamacpp provides a provider that talks to a running llama.cpp server using its OpenAI-compatible HTTP API.
|
Package llamacpp provides a provider that talks to a running llama.cpp server using its OpenAI-compatible HTTP API. |
|
llamafile
Package llamafile provides a Llamafile provider implementation for any-llm.
|
Package llamafile provides a Llamafile provider implementation for any-llm. |
|
mistral
Package mistral provides a Mistral provider implementation for any-llm.
|
Package mistral provides a Mistral provider implementation for any-llm. |
|
ollama
Package ollama provides an Ollama provider implementation for any-llm.
|
Package ollama provides an Ollama provider implementation for any-llm. |
|
openai
Package openai provides an OpenAI provider implementation for any-llm.
|
Package openai provides an OpenAI provider implementation for any-llm. |
|
platform
Package platform provides a platform provider implementation for any-llm.
|
Package platform provides a platform provider implementation for any-llm. |
|
zai
Package zai provides a z.ai provider implementation for any-llm.
|
Package zai provides a z.ai provider implementation for any-llm. |
|
Package sdk provides metadata for the any-llm-go library.
|
Package sdk provides metadata for the any-llm-go library. |