feat(v2): add OllamaCloud() constructor for Ollama Cloud
Ollama Cloud (https://ollama.com) requires a Bearer-token API key and exposes the same /api/chat surface as local Ollama. OllamaCloud(apiKey) returns a client preconfigured for the cloud endpoint; Ollama() remains the local-instance constructor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+22
-2
@@ -104,8 +104,9 @@ func Groq(apiKey string, opts ...ClientOption) *Client {
|
|||||||
return NewClient(groqProvider.New(apiKey, cfg.baseURL))
|
return NewClient(groqProvider.New(apiKey, cfg.baseURL))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ollama creates a client for a local Ollama instance (OpenAI-compatible).
|
// Ollama creates a client for a local Ollama instance using the native
|
||||||
// No API key is required. Use WithBaseURL to point at a non-default host/port.
|
// /api/chat endpoint. No API key is required. Use WithBaseURL to point at a
|
||||||
|
// non-default host/port.
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
//
|
//
|
||||||
@@ -117,3 +118,22 @@ func Ollama(opts ...ClientOption) *Client {
|
|||||||
}
|
}
|
||||||
return NewClient(ollamaProvider.New("", cfg.baseURL))
|
return NewClient(ollamaProvider.New("", cfg.baseURL))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OllamaCloud creates a client targeting Ollama Cloud (https://ollama.com).
|
||||||
|
// The apiKey is required and is sent as `Authorization: Bearer <key>`. Use
|
||||||
|
// WithBaseURL to point at a private Ollama deployment that requires auth.
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
//
|
||||||
|
// model := llm.OllamaCloud(os.Getenv("OLLAMA_API_KEY")).Model("kimi-k2.5")
|
||||||
|
func OllamaCloud(apiKey string, opts ...ClientOption) *Client {
|
||||||
|
cfg := &clientConfig{}
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(cfg)
|
||||||
|
}
|
||||||
|
baseURL := cfg.baseURL
|
||||||
|
if baseURL == "" {
|
||||||
|
baseURL = ollamaProvider.DefaultCloudBaseURL
|
||||||
|
}
|
||||||
|
return NewClient(ollamaProvider.New(apiKey, baseURL))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user