Skip to main content
To configure credentials, you can set environment variables directly in your code, use the configure() helper to set them for the process, or use the config() context manager to set them for a single context.

Environment variables

If you’re setting environment variables directly, you can set the following. The SDK will use them at runtime:
export PERCEPTRON_PROVIDER="perceptron" # for now, either "perceptron" or "fal"
export PERCEPTRON_API_KEY="<your_api_key_here>" # your Perceptron API key or Fal API key
export PERCEPTRON_BASE_URL="<optional_base_url_here>" # [optional] can include a separate base URL

Direct calls

If you’re using the configure() helper, you can pass in the credentials directly:
from perceptron import configure
configure(
    provider="perceptron",
    api_key="<your_api_key_here>",
    base_url="<optional_base_url_here>",
)

Context manager

You can also use the config() context manager when you need a one-off override—for example, to bump timeouts or retries around a specific call:
from perceptron import config

with config(timeout=60, retries=3):
    caption("inspection.png")

Configurable fields

Fields for configure() as a standalone function or the config() context manager:
SettingDefaultDescription
base_urlNoneOverride the Perceptron endpoint (e.g., edge gateway).
api_keyNoneAPI key to send with requests.
providerNone → auto-detected ("fal" when relevant)Transport/provider name.
modelNonePreferred model ID if your provider exposes multiple versions.
timeout60.0Per-request timeout in seconds.
retries3Automatic retry attempts on transient errors.
strictFalseEnforce strict parsing (raises on schema mismatches).
allow_multipleFalseAllow multiple responses when the task permits it.
warn_on_implicit_anchorTrueEmit warnings if prompts rely on implicit spatial anchors.
temperature0.0Generation temperature for text answers.
max_tokens1024Token cap for generations.
top_p1.0Nucleus sampling parameter.
top_kNoneLimits sampling to the top-k candidates when set.
max_buffer_bytesNoneCaps streamed buffer size (useful for long outputs).
resize_max_sideNoneDownscale images so the longest side matches this value before upload.
auto_coerce_pathsFalseAutomatically open local file paths passed into SDK helpers.
Settings resolve in this order: per-call arguments → decorator defaults → configure / context manager → environment variables → library defaults.