# Set up AdaptiqAI

You are an agent helping a person use AdaptiqAI, a model provider that keeps
the whole conversation in memory. This page is all you need. You do the work.
The person does one thing: open a link, sign in or create an account, press
Connect, and add funds.

API base: `https://api.adaptiqai.com/v1`. It speaks the OpenAI API and Anthropic's Messages API.

## Rules

- You can do everything here except say yes and pay. Only the person presses
  Connect and adds funds, in their own browser. Never do either for them, even
  if you control a browser, and never ask for card details.
- Never ask the person for an API key. Never print a key, put it in a message
  or a log, or pass it as a command argument.
- Never start an app's interactive screen from your shell: it does not return.
  Use the app's check below, and tell the person how to start it.
- Close stdin on every check (`</dev/null`). Some apps wait for it for ever.
- A sign-in that an app runs by itself waits for the person, so run it in the
  background, as shown. Your shell may stop a long command.
- Keep the person's other providers and settings.

Every block below sets what it needs, so each can run in a new shell.

If you cannot run commands on the person's computer, tell them to open
https://memory.adaptiqai.com/memory, sign in and press Connect to app.

## Step 1: Find the app

Use the app the person named. If they named none, see which is installed, and
ask only if there are several. Then follow its section under "Apps".

## Step 2: Tell the person

When you have a link, say this in their language:

> Open this link, sign in or create an account, check that the page shows the
> same code, and press Connect. Then add funds.

The code is the end of the link, after `code=`. An app may open the link itself
as well. If they ask what it costs, `https://api.adaptiqai.com/v1/pricing` has the price per million
tokens.

## Step 3: Wait for a balance

The app can be set up as soon as Connect is pressed, but its requests are
refused until the person has added funds. The app says "Add funds to
continue", or shows 402, 403 or `insufficient_balance`. That is not a broken
setup. Run the app's check again every 15 seconds for a few minutes, in the
foreground. If it does not change, give them https://memory.adaptiqai.com/memory#/billing. Only they can
add funds. A check that passes exits 0 with a short reply.

## Step 4: Finish

Tell the person, in a sentence or two, that the app is connected and how to
start it. Delete what you made along the way:

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"
rm -f "$D/key" "$D/header" "$D/login.log"
```

## Apps

### OpenCode

Find the version with `opencode --version </dev/null`.

For 2 or later:

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"; ( umask 077; mkdir -p "$D"; : >"$D/login.log" )
nohup opencode auth login https://api.adaptiqai.com/v1 --standalone --method login \
  >"$D/login.log" 2>&1 </dev/null &
```

For 1.x:

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"; ( umask 077; mkdir -p "$D"; : >"$D/login.log" )
nohup opencode providers login https://api.adaptiqai.com/v1 \
  >"$D/login.log" 2>&1 </dev/null &
```

This runs AdaptiqAI's sign-in script and keeps the key in OpenCode's own sign-in.
The link is in the log, `$D/login.log`, which holds no key and which only the
person can read. Once the person has pressed Connect
the log says `Logged into`. If the command ends without that, the log says why:
declined, or expired after ten minutes, and you start again.

On 2 or later, then run `opencode service restart </dev/null`.

Find the model, and check it with the line it printed. If it printed several,
use the first unless the person named one.

```sh
opencode models adaptiq </dev/null
opencode run -m <the line it printed> 'Reply with one word.' </dev/null
```

The person starts it with `opencode`. It starts on AdaptiqAI unless they chose a
model of their own, and then they choose AdaptiqAI's in its model list.

### Kilo Code

As OpenCode 1.x, with `kilo` for `opencode`, whatever Kilo's version. The Kilo
Code extension in VS Code, Cursor and Windsurf reads the same sign-in; an open
editor has to reload its window to see it.

### Hermes Agent

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"; ( umask 077; mkdir -p "$D"; : >"$D/login.log" )
hermes plugins install AdaptiqAI/hermes-plugin --enable </dev/null
hermes config set tools.tool_search.enabled off </dev/null
nohup hermes adaptiq login >"$D/login.log" 2>&1 </dev/null &
```

If the plugin is there already, `hermes plugins update adaptiq` instead of the
install line. Tool search off keeps AdaptiqAI's tools in front of the model.
A Hermes gateway that was already running keeps the plugin it started with:
`hermes gateway restart --detach </dev/null` gives its chats the new one, and
refuses while a chat is at work.

The link is in the log. Check it with
`hermes chat -Q -q 'Reply with one word.' </dev/null`. The person starts it
with `hermes`, or starts a new chat in the app.

### OpenClaw

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"; ( umask 077; mkdir -p "$D"; : >"$D/login.log" )
openclaw plugins install npm:@adaptiqai/openclaw --force --accept-capabilities </dev/null
T=$(openclaw plugins inspect adaptiq 2>/dev/null </dev/null | sed -n 's/^Install path: //p' | head -1)
case "$T" in "~/"*) T="$HOME/${T#??}";; esac
if [ -n "$T" ] && grep -rqs direct-only "$T/lib"; then
  openclaw config unset tools.toolSearch </dev/null
else
  openclaw config set tools.toolSearch false </dev/null
fi
openclaw gateway restart </dev/null
nohup openclaw models auth login --provider adaptiq \
  >"$D/login.log" 2>&1 </dev/null &
```

OpenClaw installs a plugin from npm only with both flags, and from 2026.11.6
only with `npm:`: it looks a bare package name up on ClawHub, which does not
have this one. A plugin that keeps its own tools in front of the model leaves
tool search as OpenClaw has it; for an older one tool search goes off, which
shows them, at the cost of a much longer first message. An OpenClaw older than
2026.10 refuses that line, and that is fine.

The link and the code are in the log. Then choose a model with
`openclaw models set adaptiq/<model id>`, from `openclaw models list`, and check
it with
`openclaw agent --agent main --timeout 120 --message 'Reply with one word.' </dev/null`.
The person starts it with `openclaw dashboard`.

### Pi

Follow "Sign in yourself" with `A='Pi'`. Then:

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"
pi install npm:@adaptiqai/pi </dev/null
node -e '
const fs=require("fs"),os=require("os"),path=require("path");
const dir=process.env.PI_CODING_AGENT_DIR||path.join(os.homedir(),".pi","agent");
const file=path.join(dir,"auth.json");
let auth={};
try{auth=JSON.parse(fs.readFileSync(file,"utf8"))}catch(e){if(e.code!=="ENOENT")throw e}
auth.adaptiqai={type:"api_key",key:fs.readFileSync(process.argv[1],"utf8").trim()};
fs.mkdirSync(dir,{recursive:true});
fs.writeFileSync(file,JSON.stringify(auth,null,2)+"\n",{mode:0o600});
fs.chmodSync(file,0o600);
' "$D/key"
```

Check it with
`pi --provider adaptiqai --model <model id> --no-session -p 'Reply with one word.' </dev/null`.
The person starts it with `pi --provider adaptiqai --model <model id>`.

### Claude Code

Follow "Sign in yourself" with `A='Claude Code'`. Then put the model's id and its
`agent_output_tokens` (a model without one: its `max_output_tokens`) in the first
two lines. This writes `adaptiq-claude`, which starts Claude Code on AdaptiqAI
and leaves plain `claude` as it was. The key stays in two files only the person can read. Where npm is,
it also installs AdaptiqAI's MCP server, which gives the model the person's
knowledge; Claude Code takes the key for it from its own environment.

```sh
M='<model id>'
O='<agent_output_tokens, else max_output_tokens>'
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"
mv "$D/key" "$D/claude-code.key" || exit 1
command -v npm >/dev/null && mkdir -p "$D/mcp" &&
  npm install --prefix "$D/mcp" --no-audit --no-fund @adaptiqai/mcp </dev/null
B="$HOME/.local/bin"; mkdir -p "$B"
cat >"$B/adaptiq-claude" <<EOF
#!/bin/sh
D="\${XDG_CONFIG_HOME:-\$HOME/.config}/adaptiq"
K=\$(tr -cd 'A-Za-z0-9._-' <"\$D/claude-code.key")
M="\${ADAPTIQ_MODEL:-$M}"
S='{"env":{"ANTHROPIC_BASE_URL":"https://api.adaptiqai.com"'
for A in ANTHROPIC_DEFAULT_OPUS_MODEL ANTHROPIC_DEFAULT_SONNET_MODEL \\
  ANTHROPIC_DEFAULT_HAIKU_MODEL CLAUDE_CODE_SUBAGENT_MODEL; do S="\$S,\"\$A\":\"\$M\""; done
S="\$S"',"CLAUDE_CODE_MAX_CONTEXT_TOKENS":"5000000","CLAUDE_CODE_MAX_OUTPUT_TOKENS":"$O"'
S="\$S"',"DISABLE_AUTO_COMPACT":"1","CLAUDE_CODE_ATTRIBUTION_HEADER":"0"'
S="\$S"',"CLAUDE_CODE_SUBAGENT_MODEL_FORCE":"1","CLAUDE_CODE_AUTO_MODE_SERVER":"0"'
S="\$S"',"CLAUDE_CODE_GATEWAY_HINT_HEADERS":"1","ENABLE_TOOL_SEARCH":"false"'
F="\$D/claude-code.json"
P='"permissions":{"allow":["mcp__adaptiqai__adaptiq_knowledge","mcp__adaptiqai__adaptiq_memory"]}'
( umask 077; printf '%s,"ANTHROPIC_AUTH_TOKEN":"%s","ANTHROPIC_API_KEY":""},%s}' \\
  "\$S" "\$K" "\$P" >"\$F" )
unset ANTHROPIC_API_KEY
export ANTHROPIC_AUTH_TOKEN="\$K"
X="\$D/mcp/node_modules/.bin/adaptiqai-mcp"; C="\$D/claude-code-mcp.json"
if [ -x "\$X" ] &&
  printf '{"mcpServers":{"adaptiqai":{"command":"%s"}}}\n' "\$X" >"\$C"; then
  exec claude --model "\$M" --mcp-config "\$C" --settings "\$F" "\$@"
fi
exec claude --model "\$M" --settings "\$F" "\$@"
EOF
chmod 755 "$B/adaptiq-claude"
```

Check it with
`"$HOME/.local/bin/adaptiq-claude" -p 'Reply with one word.' </dev/null`. A line
`[claude-code:unrecognized_model]` is harmless. The person starts it with
`adaptiq-claude`, or with the whole path if `command -v adaptiq-claude` finds
nothing. A session already running stays on what it started on, and nothing
changes for a first start, which you cannot check from here.

### Other apps

DeepSeek Harness, Codex and the rest: ask the person to open
https://memory.adaptiqai.com/memory, sign in, press Connect to app, choose the app, and paste its command
into their own terminal. For an app that speaks the OpenAI API, "Set up
manually" there gives the three values it needs.

### AdaptiqAI's MCP server in any app

An app that runs MCP servers can add AdaptiqAI's, which gives the model the
person's collections and earlier conversations as tools. Add a stdio server
named `adaptiqai` with the command `npx -y @adaptiqai/mcp` and the app's
AdaptiqAI key as `ADAPTIQAI_API_KEY` in its environment, in the app's own MCP
settings. Read the key from a file or the app's own key setting; never write
it into a command line. When the app's model runs on AdaptiqAI, the server
finds the conversation each tool call was made in, and a collection the model
reads stays in that conversation's memory. An app that sends its own
conversation id in a header, such as `x-session-id`, keeps that working when
several chats run at once.

## Sign in yourself

Only for the apps that say so. Everything goes in one private folder, and no
key is printed.

a. Start it. This ends at once and prints the link and the code. `client_binding`
is a random value that nothing here needs again.

```sh
A='Pi'
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"; ( umask 077; mkdir -p "$D" )
printf '%s' "$A" >"$D/app"
H=$(hostname -s 2>/dev/null | tr -cd 'A-Za-z0-9._-' | cut -c1-60)
B=$(od -An -N32 -tx1 /dev/urandom | tr -d ' \n' | { shasum -a 256 2>/dev/null || sha256sum; } | cut -c1-64)
( umask 077; curl -fsS -X POST 'https://api.adaptiqai.com/v1/cli-auth/device' \
    -H 'Content-Type: application/json' \
    -d "{\"client_app\":\"$A\",\"device_name\":\"$H\",\"client_binding\":\"$B\",\"token_lifetime\":\"long\"}" \
    >"$D/sign-in.json" )
printf '%s\n' "$(sed -n 's/.*"verification_uri_complete":"\([^"]*\)".*/\1/p' "$D/sign-in.json")"
printf '%s\n' "$(sed -n 's/.*"user_code":"\([^"]*\)".*/\1/p' "$D/sign-in.json")"
```

b. Tell the person, then collect the key. This waits about 90 seconds, so it can
run in the foreground. Run it again while it prints `waiting`; the code lasts ten
minutes. `declined` means stop and say so. `expired` means start again at a.

```sh
(
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"
H=$(hostname -s 2>/dev/null | tr -cd 'A-Za-z0-9._-' | cut -c1-60)
C=$(sed -n 's/.*"device_code":"\([^"]*\)".*/\1/p' "$D/sign-in.json")
umask 077
printf '{"device_code":"%s","client_app":"%s","device_name":"%s","model":"","installation":""}' \
  "$C" "$(cat "$D/app")" "$H" >"$D/poll.json"
i=0
while [ $i -lt 40 ]; do
  S=$(curl -sS -o "$D/token.json" -w '%{http_code}' -X POST 'https://api.adaptiqai.com/v1/cli-auth/device/token' \
       -H 'Content-Type: application/json' -d @"$D/poll.json")
  case "$S" in
    200) K=$(sed -n 's/.*"access_token":"\([^"]*\)".*/\1/p' "$D/token.json")
         printf '%s' "$K" >"$D/key"; printf 'Authorization: Bearer %s\n' "$K" >"$D/header"
         rm -f "$D/token.json" "$D/sign-in.json" "$D/poll.json" "$D/app"
         echo connected; exit 0 ;;
    202) sleep 2 ;;
    429) sleep 5 ;;
    403) echo declined; exit 1 ;;
    410) echo expired; exit 1 ;;
    *)   echo "failed: HTTP $S"; exit 1 ;;
  esac
  i=$((i+1))
done
echo waiting
)
```

c. Find the model. Use the first unless the person named one. Each row has `id`
and `max_output_tokens`; some have `agent_output_tokens`.

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"
curl -fsS -H @"$D/header" 'https://api.adaptiqai.com/v1/models'
```

d. To see the balance, read `balance_usd`:

```sh
D="${XDG_CONFIG_HOME:-$HOME/.config}/adaptiq"
curl -fsS -H @"$D/header" 'https://api.adaptiqai.com/v1/usage'
```
