← all repositories
charmbracelet/fantasy

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.

1k stars Go AgentsLanguage Models
fantasy
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

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 openaicompat package 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.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.