v0.7.0

API Key

Last updated


This page explains where ToriiDB looks for the OpenAI API key and what happens when none is found.

Lookup Order


openai.New resolves the key in this order and trims whitespace at each step:
OrderSource
1The optional apiKey argument of store.New(dir, apiKey) / daemon.New(dir, apiKey)
2OPENAI_API_KEY environment variable
3Keychain entry OPENAI_API_KEY under service ToriiDB: macOS Keychain via security; on other systems secret-tool, then an OPENAI_API_KEY=<key> line in ~/.secrets

Passing more than one apiKey value makes store.New fail with just one api key. When no key is found the store still opens; vector operations return ErrNoEmbedder (no embedder: OPENAI_API_KEY not provided). Use Session.HasEmbedder() or Daemon.HasEmbedder(ctx) to check.

中文