-
Notifications
You must be signed in to change notification settings - Fork 0
Quick Start
Arian edited this page Dec 24, 2025
·
3 revisions
- Set your API key (choose one or more):
# OpenRouter (default - access all models via one API)
export OPENROUTER_API_KEY="sk-or-..."
# Or use direct provider APIs:
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
# Ollama requires no key (runs locally)- Import the package:
import ai "gopkg.in/dragon-born/go-llm.v1"// Ask using default model (GPT-5)
resp, err := ai.Ask("What is 2+2?")
// Ask with system prompt
resp, err := ai.AskWith("Be brief", "Explain quantum physics")
// Ask specific model
resp, err := ai.AskModel(ai.ModelClaudeOpus, "Hello!")// Chain methods
resp, err := ai.GPT5().
System("You are a helpful assistant").
Temperature(0.2).
ThinkLow().
User("Hello!").
Send()
// Or use Ask() shorthand
resp, err := ai.Claude().
System("Be concise").
Ask("What is AI?")// OpenAI
ai.GPT5() // GPT-5.2 (general purpose)
ai.GPT5Codex() // GPT-5.2-Codex (code-specialized)
ai.GPT4o() // GPT-4o
// Anthropic
ai.Claude() // Claude Opus 4.5
ai.ClaudeSonnet() // Claude Sonnet 4.5
ai.ClaudeHaiku() // Claude Haiku 3.5
// Google
ai.GeminiPro() // Gemini 3 Pro (high precision, 1M context)
ai.Gemini() // Gemini 3 Flash (ultra-fast)
// xAI
ai.GrokFast() // Grok 4.1 Fast (2M context)
ai.Grok() // Grok 3
// Any model by string
ai.Use("mistralai/mistral-large")Skip OpenRouter and call providers directly:
// Direct to Anthropic
ai.Anthropic().Claude().Ask("Hello")
ai.Anthropic().ClaudeSonnet().Ask("Hello")
// Direct to OpenAI
ai.OpenAI().GPT4o().Ask("Hello")
ai.OpenAI().O1().ThinkHigh().Ask("Complex reasoning task")
// Local Ollama (no API key needed)
ai.Ollama().Use("llama3:8b").Ask("Hello")
ai.Ollama().Use("mistral").Ask("Hello")
// Ollama on different host
ai.OllamaAt("http://gpu-server:11434").Use("llama3:70b").Ask("Hello")// Load from prompts/ directory
ai.GPT5().
SystemFile("prompts/analyst.md").
Ask("Analyze the market")
// Or use the Prompt shortcut
ai.Prompt("analyst").Ask("Analyze the market")// prompts/analyst.md contains: "You analyze {{domain}} markets"
ai.GPT5().
SystemFile("prompts/analyst.md").
With(ai.Vars{"domain": "crypto"}).
Ask("What's trending?")
// Or single variable
ai.Prompt("analyst").
Var("domain", "stocks").
Ask("Market update?")- Multi-Provider Support - OpenAI, Anthropic, Google, Ollama, Azure
- Models Reference
- Builder API
- Streaming
- Advanced Features