Credentials and models
The SDK needs an LLM provider API key to run queries. There are three ways to supply credentials.
1. Reuse CLI-stored credentials (default)
Section titled “1. Reuse CLI-stored credentials (default)”If you omit settings, the session uses a file-backed Config.default(), the same configuration the saber CLI uses. 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 usual choice for local scripts on a machine where you already use SQLsaber. See Authentication.
2. Environment variables
Section titled “2. Environment variables”Both the default and in-memory configs check the provider’s environment variable first:
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:
ANTHROPIC_API_KEYOPENAI_API_KEYGOOGLE_API_KEYGROQ_API_KEYMISTRAL_API_KEYCOHERE_API_KEYHUGGINGFACE_API_KEYXAI_API_KEY
3. Pass keys in code
Section titled “3. Pass keys in code”For servers, CI, or notebooks where you do not want filesystem or keyring I/O, build an in-memory Config and inject it through settings:
from sqlsaber import SQLSaber, SQLSaberOptionsfrom 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 maps provider name to key. Supported keys are anthropic, openai, google, groq, mistral, cohere, huggingface, and xai.
For a single key without building a Config, set api_key on SQLSaberOptions. model_name is required so the provider can be determined:
options = SQLSaberOptions( database="sqlite:///my.db", model_name="anthropic:claude-sonnet-4-5-20250929", api_key="sk-...",)Select a model
Section titled “Select a model”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")SQLSaberOptions(database="...", model_name="xai:grok-4.6")If model_name is omitted, the session uses your configured default model. See Models for supported providers.
Extended thinking
Section titled “Extended thinking”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. Set thinking_enabled on its own to use the model’s default level.