Skip to main content

SDK Configuration

After installing the Ocular SDK, you’ll need to configure it with your API credentials. This guide covers all available configuration options.

Basic Configuration

All you need to get started is your API key. Everything else has sensible defaults.

Direct Initialization

This is the simplest way to get started with the SDK for testing and development.
You can also configure the SDK directly in your code:
Avoid hardcoding API keys in production code. Use environment variables instead.

Configuration Parameters

Understanding these parameters will help you optimize the SDK for your specific use case.
The SDK accepts the following parameters during initialization:
Most users will only need to set the API key. The default values work well for standard use cases.

Complete Example

Copy this example to quickly get started with a fully configured SDK instance.

Environment Variables

Using environment variables is the recommended approach for production deployments.
All configuration can be set using environment variables:
Using environment variables is recommended for production environments to keep sensitive information out of your code.

Using With Python dotenv

This approach combines the security of environment variables with the convenience of a configuration file.
For development, you can use a .env file with the python-dotenv package:
Then in your code:
Never commit your .env file to version control. Add it to your .gitignore file.