charmbracelet/fantasy
charmbracelet/fantasy has 1,056 GitHub stars and 148 forks. Star changes are not measured yet. Last checked 2026-11-09 11:29 UTC. Last push 2026-11-01.
Build AI agents with Go. Multiple providers, multiple models, one API. 🧙
Measured star growth
- in 24h
- Update delayed
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalFantasy
Build AI agents with Go. Multi-provider, multi-model, one API.
- Choose a model and provider
- Add some tools
- Compile to native machine code and let it rip
import "charm.land/fantasy"
import "charm.land/fantasy/providers/openrouter"
// Choose your fave provider.
provider, err := openrouter.New(openrouter.WithAPIKey(myHotKey))
if err != nil {
fmt.Fprintln(os.Stderr, "Whoops:", err)
os.Exit(1)
}
ctx := context.Background()
// Pick your fave model.
model, err := provider.LanguageModel(ctx, "moonshotai/kimi-k2")
if err != nil {
fmt.Fprintln(os.Stderr, "Dang:", err)
os.Exit(1)
}
// Make your own tools.
cuteDogTool := fantasy.NewAgentTool(
"cute_dog_tool",
"Provide up-to-date info on cute dogs.",
fetchCuteDogInfoFunc,
)
// Equip your agent.
agent := fantasy.NewAgent(
model,
fantasy.WithSystemPrompt("You are a moderately helpful, dog-centric assistant."),
fantasy.WithTools(cuteDogTool),
)
// Put that agent to work!
const prompt = "Find all the cute dogs in Silver Lake, Los Angeles."
result, err := agent.Generate(ctx, fantasy.AgentCall{Prompt: prompt})
if err != nil {
fmt.Fprintln(os.Stderr, "Oof:", err)
os.Exit(1)
}
fmt.Println(result.Response.Content.Text())
🍔 For the full implementation and more see the examples directory.
Multi-model? Multi-provider?
Yeah! Fantasy is designed to support a wide variety of providers and models under a single API. While many providers such as Microsoft Azure, Amazon Bedrock, and OpenRouter have dedicated packages in Fantasy, many others work just fine with openaicompat, the generic OpenAI-compatible layer. That said, if you find a provider that’s not compatible and needs special treatment, please let us know in an issue (or open a PR).
Work in Progress
We built Fantasy to power Crush, a hot coding agent for glamourously invincible development. Given that, Fantasy does not yet support things like:
- Image models
- Audio models
- PDF uploads
For things you’d like to see supported, PRs are welcome.
Whatcha think?
We’d love to hear your thoughts on this project. Need help? We gotchu. You can find us on:
Part of Charm.
Charm热爱开源 • Charm loves open source
Explore related projects
affaan-m/ECC
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
300,824 starsNousResearch/hermes-agent
The agent that grows with you
262,459 starsmultica-ai/andrej-karpathy-skills
A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.
231,876 starsfirecrawl/firecrawl
Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
200,444 stars