Skip to content

Configuration

By default, ThinkThen sends each question and its text to a model service, which answers it and bills your account. You choose the service, the model and the key with options on each command or with THINKTHEN_ environment variables.

ThinkThen keeps no answer cache, so each run asks the service again. File operations keep recovery artifacts for completed answers. Where your text goes explains their defaults, contents and cleanup.

What you have What to set
A TypeSafe account, or no account yet THINKTHEN_API_KEY. This is the default.
An OpenAI account OPENAI_API_KEY and THINKTHEN_BACKEND=openai
A gateway or a model server of your own THINKTHEN_URL for System One or OPENAI_BASE_URL for OpenAI, plus the model and key it expects

An option on the command line wins over its variable. --backend openai on one command, for example, uses OpenAI for that command only.

ThinkThen asks Jev, model jev-1.13.0, through TypeSafe's System One service at https://api.typesafe.ai/v1. You need a TypeSafe account, and each call counts against it.

  1. Sign in to the TypeSafe console.
  2. Create a key on its keys page.
  3. Set the key in your shell:
Terminal window
export THINKTHEN_API_KEY='your key'

ThinkThen reads this key from THINKTHEN_API_KEY and from no other variable.

To check which service and model answered, ask for the details with --json and keep the source:

Terminal window
echo 'Please refund my order.' |
thinkthen decide --json \
'Does the customer request a refund?' |
jq -c '.source | {backend, model}'

Output

{"backend":"systemone","model":"jev-1.13.0"}

There is no config file.

The openai backend calls OpenAI's decisions API at https://api.openai.com/v1. Its default model is gpt-6-luna. Each call counts against your OpenAI account.

  1. Create a key on your OpenAI account's API keys page.
  2. Set the key, and choose OpenAI for every command in this shell:
Terminal window
export OPENAI_API_KEY='your key'
export THINKTHEN_BACKEND=openai

To use OpenAI for one command only, leave out THINKTHEN_BACKEND and add --backend openai to that command. To use another OpenAI model, set THINKTHEN_MODEL or add --model NAME.

--url sends the same requests to another address, such as a gateway or a model you host. --model names the model that server should use. The server must speak the API of the backend you point at it:

Backend Request it sends Key it sends
systemone POST URL/systemone THINKTHEN_API_KEY
openai POST URL/decisions OPENAI_API_KEY

Each request is JSON, with the key as a bearer token in the authorization header. ThinkThen doesn't call a chat or completions endpoint.

To point System One at your server for every command in this shell:

Terminal window
export THINKTHEN_API_KEY='your server key'
export THINKTHEN_URL=https://models.example.com/v1
export THINKTHEN_MODEL=my-model

Four rules apply to the address:

  • It must use HTTPS, or plain HTTP to localhost, 127.0.0.1 or [::1]. Any other http:// address stops with usage.url before a request is sent.
  • It must not hold a user name or password, as in https://name:password@host, because ThinkThen prints the address in its settings. It stops with usage.url. Put the key in the backend's key variable instead.
  • THINKTHEN_URL sets only the System One address, taking precedence over THINKTHEN_BASE_URL. OpenAI reads OPENAI_BASE_URL. An explicit --url or SDK Settings.url overrides the address for the chosen backend, including when THINKTHEN_BACKEND chooses it.
  • If your server's certificate comes from your own certificate authority, set THINKTHEN_CA_FILE to that authority's PEM file. ThinkThen trusts it as well as your system's certificates.

The source in --json names the backend and model, so the check above shows the route each answer took.

Option Variable Default
--backend NAME THINKTHEN_BACKEND systemone
--model MODEL THINKTHEN_MODEL jev-1.13.0, or gpt-6-luna for openai
--url URL THINKTHEN_URL (System One), OPENAI_BASE_URL (OpenAI) The backend's own address
none THINKTHEN_API_KEY The System One key
none OPENAI_API_KEY The OpenAI key
none THINKTHEN_CA_FILE Your system's certificates only

THINKTHEN_MODEL applies only to commands. In an SDK, set the model on your client; without an explicit model setting, it uses the chosen backend's default model.

Command keys come only from these variables. Keep them in your shell or a secret manager, never in a script or a toolbox file. For a live backend call, a missing or blank key stops ThinkThen with usage.key-missing and exit code 2 before it sends anything. Troubleshooting lists that error and the others.

A bar you tuned on one model belongs to that model. If you change the model, check your bars again on your own messages.

Options lists every other setting.

The Go, Swift, Zig, C#, Java, Kotlin and Ruby SDKs load the native ThinkThen library when your program starts using them. They all follow one rule:

  1. If THINKTHEN_LIBRARY is set, the SDK loads that file and no other. The value must be an absolute path. A relative path stops with THINKTHEN_LIBRARY must be an absolute path, and a file that won't load stops with a local.io error that names it. An empty value counts as unset.
  2. If it isn't set, the SDK loads the library it installed, by its full path. Swift and Zig look beside your program. C# and Ruby look inside their installed package. Java, Kotlin and Go unpack the library they carry into your user cache folder and load it from there.

An SDK doesn't look in the working folder or on a system search path, so a file of the same name left there can't take the library's place. On Windows too, the SDK always gives the system a full path.

The rule has these limits:

  • It covers the ThinkThen library, not the libraries that library needs. On Windows, Go, Swift, Zig and C# keep that search to the library's own folder and the system folder. Java and Ruby can't, so Windows searches for those in its usual places.
  • On a Mac, DYLD_LIBRARY_PATH can still win over a full path, because the system checks it first.
  • A Go program built with the thinkthen_system tag links the installed library. The system loads that library when your program starts, before the SDK can read THINKTHEN_LIBRARY.

The Python, TypeScript and R packages build the engine into their own module, and C, C++ and Rust link it when you build your program, so THINKTHEN_LIBRARY doesn't apply to them.