Skip to content

Credentials & Models

The SDK needs an LLM provider API key to run queries. There are three ways to supply credentials, and you can choose whichever fits your deployment.

If you omit settings, the session uses a file-backed Config.default() — the same configuration the saber CLI uses. Any keys you saved with saber auth are picked up automatically:

from sqlsaber import SQLSaber, SQLSaberOptions
# Uses your stored CLI credentials and configured default model.
options = SQLSaberOptions(database="sqlite:///my.db")

This is the most convenient option for local scripts on a machine where you already use SQLsaber. See the Authentication guide.

Both the default and in-memory configs check the provider’s environment variable before anything else, so exporting a key just works:

Terminal window
export ANTHROPIC_API_KEY="sk-..."
options = SQLSaberOptions(
database="sqlite:///my.db",
model_name="anthropic:claude-sonnet-4-5-20250929",
)

Each provider has its own variable (e.g. ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, GROQ_API_KEY).

For servers, CI, or notebooks where you don’t want to touch the filesystem or keyring, build an in-memory Config and inject it via settings. This avoids any file or keyring I/O:

from sqlsaber import SQLSaber, SQLSaberOptions
from sqlsaber.config.settings import Config
options = SQLSaberOptions(
database="sqlite:///my.db",
settings=Config.in_memory(
model_name="anthropic:claude-sonnet-4-5-20250929",
api_keys={"anthropic": "sk-..."},
),
)

api_keys is a mapping of provider name to key. Supported provider keys are anthropic, openai, google, and groq.

For a single key without building a Config, you can also set api_key directly on SQLSaberOptions (it requires model_name so the provider can be determined):

options = SQLSaberOptions(
database="sqlite:///my.db",
model_name="anthropic:claude-sonnet-4-5-20250929",
api_key="sk-...",
)

Models are identified as "provider:model":

SQLSaberOptions(database="...", model_name="anthropic:claude-sonnet-4-5-20250929")
SQLSaberOptions(database="...", model_name="openai:gpt-5-mini")
SQLSaberOptions(database="...", model_name="google:gemini-2.5-pro")

If model_name is omitted, the session uses your configured default model. See the Models guide for the full list of supported providers.

Reasoning models support extended thinking. Enable it and pick a level:

SQLSaberOptions(
database="...",
model_name="anthropic:claude-sonnet-4-5-20250929",
thinking_level="high", # minimal | low | medium | high | maximum
)

Setting thinking_level implies thinking_enabled=True. You can also set thinking_enabled on its own to use the model’s default level.