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.
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
- ai-memory installed by following its installation guide, with the background service started by
ai-memory setup; - a Turing API key; see Get an API Key. Create a separate one for ai-memory so you can view its usage by API key.
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_dimto that model's output dimension.
- macOS
- Linux
-
Open
~/Library/Application Support/ai-memory/config.tomland 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 -
The API key reaches the service only through the
LLM_API_KEYenvironment 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.plistand add the following inside the outermost<dict>:<key>EnvironmentVariables</key><dict><key>LLM_API_KEY</key><string>your Turing API key</string></dict> -
Restrict the plist's permissions and reload the service (after editing a plist, you must
bootoutand thenbootstrap):chmod 600 ~/Library/LaunchAgents/com.github.akitaonrails.ai-memory.plistlaunchctl bootout gui/$(id -u)/com.github.akitaonrails.ai-memorylaunchctl 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.
-
Write the following to
~/.config/ai-memory/env, which the service created byai-memory setupreads:LLM_API_KEY=your Turing API keyAI_MEMORY_LLM_PROVIDER=openai-compatAI_MEMORY_LLM_BASE_URL=https://live-turing.cn.llm.tcljd.com/api/v1AI_MEMORY_LLM_MODEL=qwen3.8-flashAI_MEMORY_EMBEDDING_PROVIDER=openai-compatAI_MEMORY_EMBEDDING_BASE_URL=https://live-turing.cn.llm.tcljd.com/api/v1AI_MEMORY_EMBEDDING_MODEL=aliyun/text-embedding-v4AI_MEMORY_EMBEDDING_DIM=1024 -
Restrict the file's permissions and restart the service:
chmod 600 ~/.config/ai-memory/envsystemctl --user restart ai-memory
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.