This guide covers configuration for both Python and TypeScript SDKs, including basic setup, advanced options, and debugging capabilities.
The recommended approach to configuring the Python SDK is to use the opik configure command. This will prompt you to set up your API key and Opik instance URL (if applicable) to ensure proper routing and authentication. All details will be saved to a configuration file.
If you are using the Cloud version of the platform, you can configure the SDK by running:
You can also configure the SDK by calling configure from the Command line:
The configure methods will prompt you for the necessary information and save it to a configuration file (~/.opik.config). When using the command line version, you can use the -y or --yes flag to automatically approve any confirmation prompts:
For the TypeScript SDK, configuration is done through environment variables, constructor options, or configuration files.
Installation:
Basic Configuration:
You can configure the Opik client using environment variables in a .env file:
Or pass configuration directly to the constructor:
Both SDKs support multiple configuration approaches with different precedence orders.
Python SDK: Constructor options → Environment variables → Configuration file → Defaults
TypeScript SDK: Constructor options → Environment variables → Configuration file (~/.opik.config) → Defaults
Both SDKs support environment variables for configuration. Here’s a comparison of available options:
Both SDKs support .env files for managing environment variables. This is a good practice to avoid hardcoding secrets and to make your configuration more portable.
For Python projects, install python-dotenv:
For TypeScript projects, dotenv is automatically loaded by the SDK.
Create a .env file in your project’s root directory:
Python usage with .env file:
TypeScript usage with .env file:
The TypeScript SDK automatically loads .env files, so no additional setup is required:
Both SDKs support configuration files for persistent settings.
The Python SDK uses the TOML format. The configure method creates this file automatically, but you can also create it manually:
The TypeScript SDK also supports the same ~/.opik.config file format as the Python SDK. The configuration file uses INI format internally but shares the same structure:
By default, both SDKs look for the configuration file in your home directory (~/.opik.config). You can specify a
different location by setting the OPIK_CONFIG_PATH environment variable.
Both SDKs provide debug capabilities for troubleshooting integration issues.
The Python SDK provides two separate logging channels that can be configured independently:
Both channels support the following log levels: DEBUG, INFO (default), WARNING, ERROR, CRITICAL
To control the console log level, set the OPIK_CONSOLE_LOGGING_LEVEL environment variable before importing opik:
Available log levels for console:
DEBUG: Show all debug informationINFO: Show informational messages (default)WARNING: Show only warnings and errorsERROR: Show only errors and critical messagesCRITICAL: Show only critical errorsUsing with .env file:
The Opik SDK manages its own logging configuration. Setting log levels through Python’s standard logging.getLogger("opik").setLevel() will not work. Always use the OPIK_CONSOLE_LOGGING_LEVEL environment variable to control console output.
To enable debug mode with file logging, set these environment variables before importing opik:
Using with .env file:
Example combining both console and file logging:
Then in your Python script:
The TypeScript SDK uses structured logging with configurable levels:
Available log levels: SILLY, TRACE, DEBUG, INFO (default), WARN, ERROR, FATAL
Enable debug logging:
Or in .env file:
Programmatic control:
The Opik Python SDK uses the httpx library to make HTTP requests. The default configuration applied to the HTTP client is suitable for most use cases, but you can customize it by registering a custom httpx client hook as in following example:
Make sure to add the hook before using the Opik SDK.
The TypeScript SDK uses batching for optimal performance. You can configure batching behavior:
If you encounter the following error:
You can resolve it by either:
OPIK_CHECK_TLS_CERTIFICATE environment variable to falseREQUESTS_CA_BUNDLE environment variableIf you are experiencing problems with the Python SDK, such as receiving 400 or 500 errors from the backend, or being unable to connect at all, run the health check command:
This command will analyze your configuration and backend connectivity, providing useful insights into potential issues.

Reviewing the health check output can help pinpoint the source of the problem and suggest possible resolutions.
The TypeScript SDK validates configuration at startup. Common errors:
OPIK_URL_OVERRIDE environment variableEnable debug logging to troubleshoot issues:
If you are using the Opik Optimizer SDK, you can also enable optimizer-side debug logs:
Or programmatically:
If data isn’t appearing in Opik:
await client.flush() to force sendingload_dotenv() is called before importing opik.env files.env file should be in project root= in .env files~/.opik.configOPIK_CONFIG_PATH environment variable