> ## Documentation Index
> Fetch the complete documentation index at: https://amd-gaia.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Embed GAIA in your app

> Put the GAIA agent inside your own application. Start with gaiacpp, the native agent: an 11 to 19 MB binary that typically uses under 30 MB of memory, behind an OpenAI-compatible server, MCP or a headless command

GAIA is an agent harness you can run inside your own product, not only an app you
open. The agent, its tools and the model all run on the user's machine, so the
data your app hands it stays there unless you choose a cloud model.

Start with **`gaiacpp`**, GAIA's native agent. It is one binary with no Python
runtime, so it adds little to your app's download and almost nothing to the
user's memory. The Python agent and the SDKs are there for what `gaiacpp` does not
do yet.

## Pick a route

| You are building | Use | Your app talks to it over |
| - | - | - |
| Anything that speaks the OpenAI API: Node, Electron, Python, Go, a web backend | [`gaiacpp serve`](#the-openai-compatible-server) | `/v1/chat/completions` on `127.0.0.1` |
| A script, a CI job, a cron task | [`gaiacpp -p`](#one-headless-run) | A command, stdout and an exit code |
| Another agent or an MCP client: Claude Code, Cursor, VS Code | [`gaiacpp --mcp`](#mcp) | The Model Context Protocol, over stdio |
| A C++ app | [The C++ library](#the-c-library) | A CMake target |
| A Node or Electron app whose own interface must answer approval prompts, or that needs a tool only the Python agent has | [The Python agent as a sidecar](#the-python-agent-as-a-sidecar) | HTTP on `127.0.0.1`, streamed events |
| A Python app that builds its own agent | [The Python SDK](#the-python-sdk) | A class in your own process |

Working in Claude Code? The [`gaia-embed` plugin](https://amd-gaia.ai/docs/integrations/claude-code) gives it this
page's decisions and commands, so you can ask it to do the integration.

## Why gaiacpp

| | `gaiacpp` | The Python agent (`gaia-agent`) |
| - | - | - |
| Download | 4.8 to 7.1 MB compressed; 11 MB (Windows), 14 MB (macOS), 19 MB (Linux) unpacked | 156 to 169 MB |
| Peak memory on real tasks | 17 MB at the median and 47 MB at most, over 388 multi-step coding tasks | About 190 MB after its first turn, 208 MB after 40 |
| Start-up | Under 50 ms to start and list its 40 tools | About 5 seconds before it reads its arguments |
| One task, end to end, model time left out | 0.08 s and 11 MB | 5.9 s and 218 MB |

> [accordion] How these were measured
>
> * **Download:** the GAIA v0.27.1 release files. The Python agent's sizes are
>   the binaries the npm package downloads.
> * **gaiacpp memory:** the `peak_rss_mb` field of `gaiacpp -p --output-format json`,
>   over 388 coding tasks on Linux, a median of 36 steps each and up to 297.
>   The 90th percentile was 28 MB. In CI, 200 scripted runs that include
>   oversized replies on purpose peak at a median of 11 MB on Windows, 9 MB on
>   macOS and 15 MB on Linux, and a run over 128 MB, or a median over 30 MB,
>   fails the build. See [C++ testing](https://amd-gaia.ai/docs/cpp/testing.md).
> * **Python agent memory:** Windows, a scripted model server, 40 turns.
> * **Start-up:** one Windows PC, warm cache: `gaiacpp --mcp` from launch to
>   answering `tools/list`, and the Python agent from launch to rejecting an
>   unknown flag. Neither loads a model to start.
> * **One task, end to end:** `gaiacpp -p` and the Python agent's `gaia -p` asked
>   to read a file and answer, against a scripted model server that replies at
>   once, so the time and memory are the agent's own. The median of five runs
>   each on a Ryzen AI Max+ 395 PC running Windows, with the Python agent from
>   source on Python 3.12. Both returned the right answer; the Python agent also
>   made 26 requests to the model server where `gaiacpp` made 6, for memory and
>   statistics. A real model adds the same time to both.
> * **Idle over MCP:** `gaiacpp --mcp` holds about 10 MB on Windows while it waits.
> * No figure includes the model, which the model server holds.

What `gaiacpp` does not have yet: document-to-speech, the Claude provider, and
saved sessions. It has builds for Windows x64, Linux x64 and macOS on Apple Silicon;
there is no arm64 Linux, arm64 Windows or Intel Mac build. See
[the two harnesses](https://amd-gaia.ai/docs/reference/harnesses.md).

## Get gaiacpp

Every [GAIA release](https://github.com/amd/gaia/releases) carries a prebuilt
`gaiacpp` for each platform, with `gaiacpp-SHA256SUMS.txt` beside it.

```powershell Windows theme={null}
curl.exe -LO https://github.com/amd/gaia/releases/latest/download/gaiacpp-windows-x64.zip
Expand-Archive gaiacpp-windows-x64.zip -DestinationPath gaiacpp
.\gaiacpp\gaiacpp.exe --version
```

```bash Linux theme={null}
curl -L https://github.com/amd/gaia/releases/latest/download/gaiacpp-linux-x64.tar.gz | tar xz
./gaiacpp --version
```

```bash macOS theme={null}
curl -L https://github.com/amd/gaia/releases/latest/download/gaiacpp-darwin-arm64.tar.gz | tar xz
./gaiacpp --version
```

In a product, pin a release instead of `latest`
(`releases/download/v0.27.1/...`) and check the file against
`gaiacpp-SHA256SUMS.txt` from that release.

Every route needs a model server. After `gaia init` (see [Install](https://amd-gaia.ai/docs/guides/install.md)),
`gaiacpp` finds GAIA's [Lemonade](https://lemonade-server.ai/) server and model
with no flags. Without GAIA, point it at any OpenAI-compatible server with
`--base-url` and `-m`. See [Choosing the model endpoint](https://amd-gaia.ai/docs/cpp/gaia-agent.md#choosing-the-model-endpoint).

## The OpenAI-compatible server

Point any OpenAI client at `gaiacpp` and the agent answers, tools and all.

```bash theme={null}
export SERVE_KEY=$(openssl rand -hex 32)
gaiacpp serve --port 0 --server-key-env SERVE_KEY
```

Once it is listening it prints one JSON line on stdout, so the program that
started it learns the address:

```json theme={null}
{"event": "ready", "url": "http://127.0.0.1:41733", "model": "…", "version": "0.1.0"}
```

```python theme={null}
import os
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:41733/v1", api_key=os.environ["SERVE_KEY"])
reply = client.chat.completions.create(
    model="gaia",  # not used: the server runs the model it started with
    messages=[{"role": "user", "content": "What is in my Downloads folder?"}],
)
```

**What to know**

* `--server-key-env` is required, and clients send that key as a bearer token.
  In this mode **tools run without asking**, so whoever holds the key decides what
  runs. Start the server from your app, keep the key in memory, and never ship it
  in source.
* It binds `127.0.0.1`, refuses browser requests unless you allow their origin
  with `--allow-origin`, and answers `GET /health` without a key for readiness
  checks.
* Each request carries its whole conversation; the server keeps nothing between
  requests and runs one at a time (a second gets 409).
* With `stream: true`, steps and tool calls arrive as they happen. See
  [Server mode](https://amd-gaia.ai/docs/cpp/gaia-agent.md#server-mode) for every route.

## One headless run

For a script, one command in and one answer out:

```bash theme={null}
gaiacpp -p "List the Python files here" --output-format json
```

The answer goes to stdout and the exit code is 0 or 1. The JSON record also
carries the steps taken, the tokens used and `peak_rss_mb`, the run's peak
memory. Tools that change something (shell commands that change something, file
writes) are refused unless you pass `--dangerously-skip-permissions`, and each
refusal is reported on stderr. A command GAIA cannot check, such as `python` or
`make`, also needs `--full-access`, which lifts the folder limit too. See
[Headless runs](https://amd-gaia.ai/docs/cpp/gaia-agent.md#headless-runs).

## MCP

`gaiacpp --mcp` gives another program's agent GAIA's tools (files, shell, git,
documents, code search, web search and fetch, memory) over MCP. It contacts no
model, so the calling agent's model does the thinking.

```bash theme={null}
claude mcp add gaia -- gaiacpp --mcp --cwd /path/to/project
```

Any MCP client takes the same command:

```json theme={null}
{"mcpServers": {"gaia": {"command": "gaiacpp", "args": ["--mcp", "--cwd", "/path/to/project"]}}}
```

**What to know**

* The tools stay inside the `--cwd` folder and any folder added with `--allow-dir`.
* Nobody can answer an approval prompt over MCP, so a tool that changes something
  is refused unless the server was started with `--dangerously-skip-permissions`.
  A command GAIA cannot check, such as `python` or `make`, also needs `--full-access`.
* GAIA is also an MCP client: `gaiacpp --mcp-config mcp.json` gives the agent other
  MCP servers' tools. See [MCP servers](https://amd-gaia.ai/docs/cpp/gaia-agent.md#mcp-servers).
* The Python agent has its own HTTP bridge, `gaia mcp start`, which exposes whole
  agents rather than tools. See [MCP](https://amd-gaia.ai/docs/integrations/mcp.md).

## The C++ library

The C++17 framework `gaiacpp` is built on, for an agent of your own inside a C++
app. Its dependencies are fetched for you.

```cmake theme={null}
include(FetchContent)
FetchContent_Declare(
    gaia
    GIT_REPOSITORY https://github.com/amd/gaia.git
    GIT_TAG        v0.27.1   # a release tag, not main
    SOURCE_SUBDIR  cpp
)
FetchContent_MakeAvailable(gaia)

target_link_libraries(my_app PRIVATE gaia::gaia_core)
```

**What to know**

* Needs CMake 3.14 or newer and a C++17 compiler.
* Pin `GIT_TAG` to a [release tag](https://github.com/amd/gaia/releases). `main`
  changes many times a day.
* See [Integration](https://amd-gaia.ai/docs/cpp/integration.md) for submodule, `find_package` and shared
  library builds.

## The Python agent as a sidecar

The Python agent, every tool included, as a program your app starts and talks
to over HTTP. This is the route the GAIA desktop app uses. Choose it over
`gaiacpp serve` when your own interface has to answer approval prompts, or when
you need a tool only the Python agent has.

```bash theme={null}
npx @amd-gaia/gaia serve --port 8141
curl http://127.0.0.1:8141/health
```

From Node, the same package downloads the agent, checks its SHA-256 against a
manifest shipped in the package, starts it and hands you its address and token:

```ts theme={null}
import { randomUUID } from "node:crypto";
import { fetchAll, startSidecar, shutdown } from "@amd-gaia/gaia";

const { sidecar } = await fetchAll();
const proc = await startSidecar({ binaryPath: sidecar.binaryPath });

const res = await fetch(`${proc.baseUrl}/v1/gaia/query`, {
  method: "POST",
  headers: {
    "content-type": "application/json",
    authorization: `Bearer ${proc.authToken}`,
  },
  body: JSON.stringify({
    query: "summarize my notes",
    run_id: randomUUID(),
    session_id: randomUUID(), // reuse it for every turn of one conversation
    context: [],
  }),
});

await shutdown(proc);
```

The answer is a stream of Server-Sent Events that ends with exactly one `final` or
`error` event. Tool calls that need the user's approval arrive as events your app
answers, so your UI decides how to ask.

**What to know**

* The agent it downloads is 156 to 169 MB, and uses about 190 MB of memory once
  running.
* It binds to `127.0.0.1`, and every `/v1/gaia/*` request needs a bearer token
  minted fresh at each start.
* The contract is versioned. `GET /version` reports it; a change in the major
  number is a breaking change, and a higher minor only adds things. See
  [Releases and stability](https://amd-gaia.ai/docs/reference/stability.md#the-sidecar-contract).
* Needs Node.js 18 or newer.
* The agent has builds for Windows x64, macOS (Apple Silicon and Intel) and Linux
  x64 (glibc 2.34 or newer; GAIA's model server needs 2.38, so a local model
  means Ubuntu 24.04 or newer). **There is no arm64 Linux or arm64 Windows build.**

The package's
[README](https://github.com/amd/gaia/blob/main/hub/agents/gaia/npm/README.md) and
[SPEC](https://github.com/amd/gaia/blob/main/hub/agents/gaia/npm/SPEC.md) hold the
full endpoint and event reference.

The Python agent also has an OpenAI-compatible server, `gaia api start`, which
refuses tools that need approval instead of running them. It needs a source
install of GAIA; see [API Server](https://amd-gaia.ai/docs/sdk/infrastructure/api-server.md). For headless
runs it has `gaia -p`; see the [CLI reference](https://amd-gaia.ai/docs/reference/cli.md).

## The Python SDK

Subclass `Agent` in your own process. You write a system prompt and the tools;
the base class runs the loop, calls the model, parses tool calls and recovers
from errors.

```bash theme={null}
pip install amd-gaia
```

```python theme={null}
from gaia.agents.base.agent import Agent
from gaia.agents.base.console import AgentConsole


class MinimalAgent(Agent):
    def _get_system_prompt(self) -> str:
        return "You are a helpful assistant."

    def _create_console(self):
        return AgentConsole()

    def _register_tools(self):
        pass


agent = MinimalAgent()
print(agent.process_query("Hello! What can you help me with?")["result"])
```

**What to know**

* Needs Python 3.10 or newer.
* Ready-made tool sets (documents, files, shell, web, SQL) are mixins you add by
  name. See [Agent System](https://amd-gaia.ai/docs/sdk/core/agent-system.md) and the [SDK reference](https://amd-gaia.ai/docs/sdk.md).

## When GAIA fits, and when it does not

**GAIA fits when**

* The agent has to run on the user's own machine, and their files and prompts
  should stay there.
* You want a whole harness, not a model client: the tool loop, folder limits and
  approval for risky actions, document search, memory and skills already built
  and tested.
* The agent must stay small: `gaiacpp` adds a few megabytes to your download and
  tens of megabytes of memory.
* Your users are on Windows, macOS (Apple Silicon) or Linux PCs, and all the more
  so on AMD Ryzen AI hardware, where the models run on the integrated GPU, or on
  the NPU when the user chooses it.
* You need a permissive licence. GAIA is MIT.

**Look elsewhere when**

* You need a hosted, multi-tenant agent service. GAIA runs one user's agent on
  one machine; it is not a cloud backend.
* Your target is a phone, a browser tab, arm64 Linux or arm64 Windows.
* The machine has less than 8 GB of RAM and you want a local model. A cloud model
  you opt into works there; a local one does not.
* You need a 1.0 API guarantee today. GAIA is on 0.x: stable releases are tested
  and gated, but a minor release can still change an API. Pin a version and read
  [Releases and stability](https://amd-gaia.ai/docs/reference/stability.md) for exactly what is promised.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.