A Go framework for AI agents that swaps LLMs without rewriting code
Fantasy is a Go library that unifies multiple LLM providers under one typed API so you can build tool-wielding agents and swap models by changing a string.

What it does
Fantasy is a Go library for building AI agents that can invoke custom tools written as ordinary functions. You initialize a provider, select a model, attach your tools, and prompt the agent; the library manages the request loop and response parsing. It was built specifically to power Charm’s own coding agent, Crush.
The interesting bit
Instead of wrapping each provider’s quirks separately, Fantasy funnels Azure, Amazon Bedrock, OpenRouter, and generic OpenAI-compatible endpoints through the same Go types. The README claims you can switch providers by swapping a model string and recompiling.
Key highlights
- First-class support for Azure, Bedrock, and OpenRouter, plus a fallback
openaicompatpackage for anything that mimics OpenAI’s protocol. - Tool calling is built in: register Go functions as named capabilities the agent can invoke during generation.
- The API is strongly typed rather than a thin wrapper around raw JSON payloads.
- Examples in the repository show full agent implementations with provider setup and tool definitions.
Caveats
- Image generation, audio models, and PDF uploads are explicitly listed as not yet supported.
- The README admits some providers may still need “special treatment” beyond the generic compatibility layer, so universal plug-and-play is aspirational.
Verdict
A solid candidate if you are writing agent-backed Go tools and want to postpone picking an LLM vendor. Look elsewhere if you need multimodal features or a no-code solution.
Frequently asked
- What is charmbracelet/fantasy?
- Fantasy is a Go library that unifies multiple LLM providers under one typed API so you can build tool-wielding agents and swap models by changing a string.
- Is fantasy open source?
- Yes — charmbracelet/fantasy is open source, released under the Apache-2.0 license.
- What language is fantasy written in?
- charmbracelet/fantasy is primarily written in Go.
- How popular is fantasy?
- charmbracelet/fantasy has 1k stars on GitHub.
- Where can I find fantasy?
- charmbracelet/fantasy is on GitHub at https://github.com/charmbracelet/fantasy.