Skip to content

configure()

Configure the global Gavrun client. Call once at startup before any guarded tool calls.

python
import gavrun

client = gavrun.configure(
    api_key="gavrun_live_...",
    agent_name="my-agent",
    agent_manager_url="https://api.gavrun.ai",
)

Signature

python
def configure(
    *,
    api_key: str | None = None,
    agent_name: str | None = None,
    agent_manager_url: str | None = None,
    environment: str | None = None,
    mode: str | None = None,
    auto_patch: bool = True,
    dotenv_path: str | None = ".env",
) -> GavrunClient

All parameters are keyword-only.

Parameters

ParameterTypeDefaultDescription
api_keystrenv GAVRUN_API_KEYSDK API key from the dashboard.
agent_namestrenv GAVRUN_AGENT_NAMEStable identifier for this agent.
agent_manager_urlstrenv GAVRUN_AGENT_MANAGER_URLRequired. API base URL. Use https://api.gavrun.ai for production.
environmentstrenv GAVRUN_ENV or "dev"Deployment environment: "dev", "staging", or "prod".
modestrenv GAVRUN_MODE or "enforce"See Modes.
auto_patchboolTrueAuto-instrument LangChain, LangGraph, CrewAI, and OpenAI Agents SDK.
dotenv_pathstr | None".env"Path to a .env file to load before resolving other parameters. None to skip.

Environment variables

All parameters fall back to environment variables:

ParameterEnv var
api_keyGAVRUN_API_KEY
agent_nameGAVRUN_AGENT_NAME
agent_manager_urlGAVRUN_AGENT_MANAGER_URL
environmentGAVRUN_ENV
modeGAVRUN_MODE

Errors

  • GavrunError — raised if agent_manager_url is not set (neither as argument nor env var).

Returns

GavrunClient — the global singleton client. Retrieve it later with gavrun.get_client().

Example: explicit config

python
import gavrun

gavrun.configure(
    api_key="gavrun_live_abc123",
    agent_name="support-agent",
    agent_manager_url="https://api.gavrun.ai",
    environment="prod",
    mode="enforce",
)

Example: env-only config

bash
# .env
GAVRUN_API_KEY=gavrun_live_abc123
GAVRUN_AGENT_NAME=support-agent
GAVRUN_AGENT_MANAGER_URL=https://api.gavrun.ai
GAVRUN_ENV=prod
python
import gavrun
gavrun.configure()   # reads all values from env / .env file

Apache 2.0 License