Skip to main content

Use Turing Models in ai-memory

ai-memory is an open-source (MIT) local memory service. It runs on your own computer, records sessions through the hooks of agents such as Claude Code and Codex, and lets another agent recall earlier work or carry on with the same task. It is a third-party project that Turing does not maintain or support.

This page covers only how to route ai-memory's model and embedding requests through the Turing API. For installation, connecting agents, and daily use, follow the ai-memory documentation.

How it relates to Agent Memory

Agent Memory stores the long-term preferences and decisions you confirm. It lives in Turing and is shared by your agents and Portal. ai-memory records the sessions on your machine to continue the current task, and its data stays on your computer. You can use both: Agent Memory works through a Skill and installs no hooks, so it does not conflict with ai-memory's hooks.

Why configure models​

ai-memory works without any model: sessions are summarized by rules, and search uses a local embedding model. That local model is downloaded from huggingface.co on first start, which may fail on networks in mainland China; search then falls back to keywords only. The model is also mainly for English.

With Turing models configured:

  • Turing generates the embeddings, so no local model is downloaded, and Chinese content is searchable by meaning;
  • a chat model rewrites sessions into pages that are easier to read.

Once enabled, the text of session pages is sent to the Turing API, and the usage counts toward your API key. Existing pages are re-embedded in the background, which also incurs usage.

Prerequisites​

Configure​

The examples below use the China region. For another region, use that region's API address (see Get an API Key) and models available there:

  • a small non-reasoning chat model is enough, since ai-memory uses it only to summarize;
  • when you change the embedding model, set embedding_dim to that model's output dimension.
  1. Open ~/Library/Application Support/ai-memory/config.toml and add these lines at the top of the file, before the first [...] section. Lines added at the end of the file land in the [auth] section and have no effect.

    llm_provider = "openai-compat"
    llm_base_url = "https://live-turing.cn.llm.tcljd.com/api/v1"
    llm_model = "qwen3.8-flash"
    embedding_provider = "openai-compat"
    embedding_base_url = "https://live-turing.cn.llm.tcljd.com/api/v1"
    embedding_model = "aliyun/text-embedding-v4"
    embedding_dim = 1024
  2. The API key reaches the service only through the LLM_API_KEY environment variable. On macOS the service is a LaunchAgent, which has no environment file, so the key goes into its plist: open ~/Library/LaunchAgents/com.github.akitaonrails.ai-memory.plist and add the following inside the outermost <dict>:

    <key>EnvironmentVariables</key>
    <dict>
    <key>LLM_API_KEY</key>
    <string>your Turing API key</string>
    </dict>
  3. Restrict the plist's permissions and reload the service (after editing a plist, you must bootout and then bootstrap):

    chmod 600 ~/Library/LaunchAgents/com.github.akitaonrails.ai-memory.plist
    launchctl bootout gui/$(id -u)/com.github.akitaonrails.ai-memory
    launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.github.akitaonrails.ai-memory.plist

Re-running ai-memory setup rewrites this plist from its template and removes EnvironmentVariables; repeat steps 2 and 3 afterwards.

When no separate embedding key is set, embeddings reuse LLM_API_KEY; you do not need a second key.

Verify​

ai-memory status

The configuration is in effect when the two lines under Optional models show the Turing models with ok:

llm: openai-compat/qwen3.8-flash ok (last call: ...)
embedding: openai-compat/aliyun/text-embedding-v4 (1024d) ok (last call: ...)

Right after a restart, before any call, they show unknown (no calls yet); check again after a few turns with an agent. When a line shows error, the parentheses hold the status code and error message returned by Turing.

Troubleshooting​

  • Errors returned by Turing (such as 401, 403, or 429): see the Error Codes reference, or contact the operations team via Get Help.
  • Problems with ai-memory itself: report them in its GitHub Issues.
Self-check